brumate 0.2.0 → 0.3.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/{boot-D-IdPy7B.d.ts → boot-C25Sa6vq.d.ts} +5 -2
- package/dist/cli.js +2 -2
- package/dist/{client-C0UCNL3J.js → client-BD6XT-s5.js} +435 -110
- package/dist/client-BD6XT-s5.js.map +1 -0
- package/dist/{client-MD0ZmcFR.d.ts → client-D0CqSxoO.d.ts} +114 -8
- package/dist/{cookies-Av5WFmcf.js → cookies-BzllthiF.js} +2 -1
- package/dist/cookies-BzllthiF.js.map +1 -0
- package/dist/{defer-D0bo1Gqx.js → defer-BbD7JQhj.js} +6 -2
- package/dist/defer-BbD7JQhj.js.map +1 -0
- package/dist/devtools-CQgD7NPB.js +623 -0
- package/dist/devtools-CQgD7NPB.js.map +1 -0
- package/dist/devtools-panel-BVB-W5q4.js +1930 -0
- package/dist/devtools-panel-BVB-W5q4.js.map +1 -0
- package/dist/events-CSs7OwIC.js +85 -0
- package/dist/events-CSs7OwIC.js.map +1 -0
- package/dist/{files-Bnn1JqHx.js → files-BXSSrQgc.js} +18 -5
- package/dist/files-BXSSrQgc.js.map +1 -0
- package/dist/forms-Bg-CwGqX.js +406 -0
- package/dist/forms-Bg-CwGqX.js.map +1 -0
- package/dist/forms-Cl21hkHt.d.ts +281 -0
- package/dist/highlight.d.ts +17 -0
- package/dist/highlight.js +269 -0
- package/dist/highlight.js.map +1 -0
- package/dist/{html-y1q7-t7D.d.ts → html-Bq1rFxX_.d.ts} +36 -4
- package/dist/{html-bHZbkK-h.js → html-mNTKzaDD.js} +79 -8
- package/dist/html-mNTKzaDD.js.map +1 -0
- package/dist/index.d.ts +47 -2
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/{inspect-BJtACnQp.js → inspect-BHpOw1LF.js} +625 -48
- package/dist/inspect-BHpOw1LF.js.map +1 -0
- package/dist/{loader-B18i3_-T.js → loader-Dos_3NP0.js} +5 -4
- package/dist/loader-Dos_3NP0.js.map +1 -0
- package/dist/{navigate-BwuZveDF.js → navigate-O78d_zGN.js} +45 -2
- package/dist/navigate-O78d_zGN.js.map +1 -0
- package/dist/{produce-D4K7qpaL.d.ts → produce-D0V0ICkz.d.ts} +45 -3
- package/dist/{produce-CWfJ4byV.js → produce-Doc91GkX.js} +113 -6
- package/dist/produce-Doc91GkX.js.map +1 -0
- package/dist/{rpc-B-Zkn6Ch.js → rpc-ygMRPmN4.js} +20 -10
- package/dist/rpc-ygMRPmN4.js.map +1 -0
- package/dist/runtime/client.d.ts +4 -4
- package/dist/runtime/client.js +4 -4
- package/dist/runtime/devtools.d.ts +188 -3
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/events.d.ts +15 -0
- package/dist/runtime/events.js +1 -1
- package/dist/runtime/forms.d.ts +2 -0
- package/dist/runtime/forms.js +1 -0
- package/dist/runtime/gather.d.ts +25 -0
- package/dist/runtime/gather.js +33 -0
- package/dist/runtime/gather.js.map +1 -0
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/html.d.ts +2 -2
- package/dist/runtime/html.js +1 -1
- package/dist/runtime/loader.d.ts +2 -2
- package/dist/runtime/loader.js +2 -2
- package/dist/runtime/server.d.ts +5 -4
- package/dist/runtime/server.js +5 -5
- package/dist/runtime/signals.d.ts +38 -2
- package/dist/runtime/signals.js +12 -2
- package/dist/runtime/signals.js.map +1 -1
- package/dist/runtime/static-loader.d.ts +2 -2
- package/dist/runtime/static-loader.js +1 -1
- package/dist/runtime/testing.d.ts +2 -2
- package/dist/runtime/testing.js +2 -2
- package/dist/runtime/values.d.ts +2 -0
- package/dist/runtime/values.js +24 -0
- package/dist/runtime/values.js.map +1 -0
- package/dist/{server-BqfM95r1.js → server-CxVDYE_V.js} +776 -121
- package/dist/server-CxVDYE_V.js.map +1 -0
- package/dist/{server-BA9SJ2Vm.d.ts → server-DuFYRXrd.d.ts} +284 -15
- package/dist/{static-loader-BzE9SRaj.d.ts → static-loader-Drpr0AzI.d.ts} +2 -2
- package/dist/{static-loader-DOygOFj5.js → static-loader-nZssh66R.js} +168 -51
- package/dist/static-loader-nZssh66R.js.map +1 -0
- package/dist/{stream-JaMHMdBD.js → stream-DCYZO4IF.js} +89 -10
- package/dist/stream-DCYZO4IF.js.map +1 -0
- package/dist/values-B8C7CLvG.d.ts +63 -0
- package/dist/vite.d.ts +8 -1
- package/dist/vite.js +170 -20
- package/dist/vite.js.map +1 -1
- package/forms/forms.brm.ts +141 -0
- package/package.json +31 -2
- package/dist/client-C0UCNL3J.js.map +0 -1
- package/dist/cookies-Av5WFmcf.js.map +0 -1
- package/dist/defer-D0bo1Gqx.js.map +0 -1
- package/dist/devtools-C50VH8gZ.js +0 -113
- package/dist/devtools-C50VH8gZ.js.map +0 -1
- package/dist/devtools-panel-AYjfwPhj.js +0 -435
- package/dist/devtools-panel-AYjfwPhj.js.map +0 -1
- package/dist/events-BKWRqtMg.js +0 -52
- package/dist/events-BKWRqtMg.js.map +0 -1
- package/dist/files-Bnn1JqHx.js.map +0 -1
- package/dist/html-bHZbkK-h.js.map +0 -1
- package/dist/inspect-BJtACnQp.js.map +0 -1
- package/dist/loader-B18i3_-T.js.map +0 -1
- package/dist/navigate-BwuZveDF.js.map +0 -1
- package/dist/produce-CWfJ4byV.js.map +0 -1
- package/dist/rpc-B-Zkn6Ch.js.map +0 -1
- package/dist/server-BqfM95r1.js.map +0 -1
- package/dist/static-loader-DOygOFj5.js.map +0 -1
- package/dist/stream-JaMHMdBD.js.map +0 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/runtime/values.ts
|
|
2
|
+
/**
|
|
3
|
+
* Makes a plugin for a value of the app. Export it from the entry,
|
|
4
|
+
* `src/serial.ts`, in `plugins`:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* export const plugins = [
|
|
8
|
+
* definePlugin({
|
|
9
|
+
* tag: 'app/money',
|
|
10
|
+
* test: (value) => value instanceof Money,
|
|
11
|
+
* toData: (money: Money) => [money.amount, money.currency],
|
|
12
|
+
* fromData: ([amount, currency]) => new Money(amount, currency),
|
|
13
|
+
* }),
|
|
14
|
+
* ];
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
function definePlugin(plugin) {
|
|
18
|
+
if (!plugin.tag || plugin.tag.startsWith("brumate/")) throw new Error(`A plugin needs a tag of its own, such as 'app/money', and "${plugin.tag}" is not one`);
|
|
19
|
+
return plugin;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { definePlugin };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.js","names":[],"sources":["../../src/runtime/values.ts"],"sourcesContent":["// `brumate/serial`: plugins for values of the app, such as a class, so the\n// page state and server function calls can hold them. An entry of the app,\n// `src/serial.ts`, exports them as `plugins`. This module has no code of\n// seroval, so the browser loads it with the entry and nothing more.\n\n/**\n * How a value of the app becomes data that brumate can send, and back.\n * `data` can hold anything that brumate sends, such as numbers, strings,\n * arrays, plain objects and dates.\n */\n// oxlint-disable-next-line typescript/no-explicit-any -- The data of a plugin is any value that brumate sends.\nexport interface ValuePlugin<T = any, D = any> {\n /** A name of the plugin that no other plugin has, such as `app/money`. */\n tag: string;\n /** True for a value of the plugin, such as `value instanceof Money`. */\n test: (value: unknown) => boolean;\n /** The data of a value, such as `[money.amount, money.currency]`. */\n toData: (value: T) => D;\n /** Makes the value again from its data, in the browser or on the server. */\n fromData: (data: D) => T;\n}\n\n/**\n * Makes a plugin for a value of the app. Export it from the entry,\n * `src/serial.ts`, in `plugins`:\n *\n * ```ts\n * export const plugins = [\n * definePlugin({\n * tag: 'app/money',\n * test: (value) => value instanceof Money,\n * toData: (money: Money) => [money.amount, money.currency],\n * fromData: ([amount, currency]) => new Money(amount, currency),\n * }),\n * ];\n * ```\n */\nexport function definePlugin<T, D>(plugin: ValuePlugin<T, D>): ValuePlugin<T, D> {\n if (!plugin.tag || plugin.tag.startsWith('brumate/')) {\n throw new Error(\n `A plugin needs a tag of its own, such as 'app/money', and \"${plugin.tag}\" is not one`,\n );\n }\n return plugin;\n}\n\n/** The exports of the serial entry, `src/serial.ts`. Each is optional. */\nexport interface SerialEntry {\n /** Plugins for values of the app, which `definePlugin` makes. */\n plugins?: readonly ValuePlugin[];\n /**\n * The features of seroval that are off, as its `Feature` flags. Brumate\n * turns off `ErrorPrototypeStack` and `RegExp`, and warns when the entry\n * turns one of them on.\n */\n disabledFeatures?: number;\n /** How deep a value can be. Deeper values throw instead of being sent. */\n depthLimit?: number;\n}\n\n/**\n * The values that plugins of the app send, for the type checker. Add each\n * class to it, so a signal or memo can hold one:\n *\n * ```ts\n * declare module 'brumate/serial' {\n * interface SendableValues {\n * money: Money;\n * }\n * }\n * ```\n */\n// oxlint-disable-next-line typescript/no-empty-interface -- Apps add to it with declaration merging.\nexport interface SendableValues {}\n\n/** A value that a plugin of the app sends. */\nexport type AppValue = SendableValues[keyof SendableValues];\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,SAAgB,aAAmB,QAA8C;CAC/E,IAAI,CAAC,OAAO,OAAO,OAAO,IAAI,WAAW,UAAU,GACjD,MAAM,IAAI,MACR,8DAA8D,OAAO,IAAI,aAC3E;CAEF,OAAO;AACT"}
|