roamjs-components 0.57.4 → 0.57.7

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "roamjs-components",
3
3
  "description": "Description for roamjs-components",
4
- "version": "0.57.4",
4
+ "version": "0.57.7",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "scripts": {
package/types/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { ClientParams, DatalogClause, PullBlock, RoamBasicNode, RoamBlock, SidebarAction, SidebarWindow, SidebarWindowInput, WriteAction } from "./native";
3
3
  import { Condition as QueryBuilderCondition, Selection as QueryBuilderSelection, Result as QueryBuilderResult, ExportTypes } from "./query-builder";
4
- import { CommandHandler, SmartBlocksContext } from "./smartblocks";
4
+ import { RegisterCommand } from "./smartblocks";
5
5
  export * from "./native";
6
6
  declare type json = string | number | boolean | null | {
7
7
  toJSON: () => string;
@@ -222,8 +222,9 @@ declare global {
222
222
  pull: (a: {
223
223
  returnNode: string;
224
224
  match: RegExpExecArray;
225
+ where: DatalogClause[];
225
226
  }) => string;
226
- mapper: (r: PullBlock, key: string) => QueryBuilderResult[string];
227
+ mapper: (r: PullBlock, key: string) => QueryBuilderResult[string] | Record<string, QueryBuilderResult[string]> | Promise<QueryBuilderResult[string] | Record<string, QueryBuilderResult[string]>>;
227
228
  }) => void;
228
229
  };
229
230
  versioning?: {
@@ -233,12 +234,7 @@ declare global {
233
234
  }) => void;
234
235
  };
235
236
  smartblocks?: {
236
- registerCommand: (args: {
237
- text: string;
238
- help?: string;
239
- handler: (c: Pick<SmartBlocksContext, "targetUid" | "variables">) => CommandHandler;
240
- delayArgs?: true;
241
- }) => void;
237
+ registerCommand: RegisterCommand;
242
238
  triggerSmartblock: (args: {
243
239
  srcName?: string;
244
240
  srcUid?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/types/index.ts"],"names":[],"mappings":";;;AAQA,wDAAyB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/types/index.ts"],"names":[],"mappings":";;;AAkBA,wDAAyB"}
@@ -22,4 +22,12 @@ export declare type SmartBlocksContext = {
22
22
  refMapping: Record<string, string>;
23
23
  afterWorkflowMethods: (() => void | Promise<void>)[];
24
24
  };
25
+ export declare type RegisterCommand = (args: {
26
+ text: string;
27
+ help?: string;
28
+ handler: (c: Pick<SmartBlocksContext, "targetUid" | "variables"> & {
29
+ proccessBlockText: (s: string) => Promise<InputTextNode[]>;
30
+ }) => CommandHandler;
31
+ delayArgs?: true;
32
+ }) => void;
25
33
  export {};
@@ -1,6 +1,3 @@
1
- import { CommandHandler } from "../types/smartblocks";
2
- declare const registerSmartBlocksCommand: ({ text: inputText, handler, }: {
3
- text: string;
4
- handler: (u: unknown) => CommandHandler;
5
- }) => void;
1
+ import { RegisterCommand } from "../types/smartblocks";
2
+ declare const registerSmartBlocksCommand: RegisterCommand;
6
3
  export default registerSmartBlocksCommand;
@@ -1,25 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const registerSmartBlocksCommand = ({ text: inputText, handler, }) => {
4
- const text = inputText.toUpperCase();
5
- const register = (retry) => {
6
- var _a, _b;
7
- return ((_b = (_a = window.roamjs) === null || _a === void 0 ? void 0 : _a.extension) === null || _b === void 0 ? void 0 : _b.smartblocks)
8
- ? window.roamjs.extension.smartblocks.registerCommand({
9
- text,
10
- handler,
11
- })
12
- : retry === 120 && window.roamjs
13
- ? !(window.roamjs = Object.assign(Object.assign({}, window.roamjs), { extension: Object.assign(Object.assign({}, window.roamjs.extension), { [text]: Object.assign(Object.assign({}, window.roamjs.extension[text]), { registerSmartBlocksCommand: () => {
14
- var _a, _b;
15
- (_b = (_a = window.roamjs) === null || _a === void 0 ? void 0 : _a.extension.smartblocks) === null || _b === void 0 ? void 0 : _b.registerCommand({
16
- text,
17
- handler,
18
- });
19
- } }) }) }))
20
- : window.setTimeout(() => register(retry + 1), 1000);
21
- };
22
- register(0);
3
+ const registerSmartBlocksCommand = (args) => {
4
+ var _a, _b;
5
+ if ((_b = (_a = window.roamjs) === null || _a === void 0 ? void 0 : _a.extension) === null || _b === void 0 ? void 0 : _b.smartblocks) {
6
+ window.roamjs.extension.smartblocks.registerCommand(args);
7
+ }
8
+ else {
9
+ document.body.addEventListener(`roamjs:smartblocks:loaded`, () => {
10
+ var _a;
11
+ return ((_a = window.roamjs) === null || _a === void 0 ? void 0 : _a.extension.smartblocks) &&
12
+ window.roamjs.extension.smartblocks.registerCommand(args);
13
+ });
14
+ }
23
15
  };
24
16
  exports.default = registerSmartBlocksCommand;
25
17
  //# sourceMappingURL=registerSmartBlocksCommand.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registerSmartBlocksCommand.js","sourceRoot":"","sources":["../src/util/registerSmartBlocksCommand.ts"],"names":[],"mappings":";;AAEA,MAAM,0BAA0B,GAAG,CAAC,EAClC,IAAI,EAAE,SAAS,EACf,OAAO,GAIR,EAAQ,EAAE;IACT,MAAM,IAAI,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAyB,EAAE;;QACxD,OAAA,CAAA,MAAA,MAAA,MAAM,CAAC,MAAM,0CAAE,SAAS,0CAAE,WAAW;YACnC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,eAAe,CAAC;gBAClD,IAAI;gBACJ,OAAO;aACR,CAAC;YACJ,CAAC,CAAC,KAAK,KAAK,GAAG,IAAI,MAAM,CAAC,MAAM;gBAChC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,mCACV,MAAM,CAAC,MAAM,KAChB,SAAS,kCACJ,MAAM,CAAC,MAAM,CAAC,SAAS,KAC1B,CAAC,IAAI,CAAC,kCACD,MAAM,CAAC,MAAM,CAAC,SAAS,CA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