@dosgato/templating 0.0.123 → 0.0.125

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/component.js CHANGED
@@ -1,4 +1,4 @@
1
- import { get, isNotBlank, printIf, titleCase } from 'txstate-utils';
1
+ import { get, isNotBlank, titleCase } from 'txstate-utils';
2
2
  import { ResourceProvider } from './provider.js';
3
3
  function defaultWrap(info) { return info.output; }
4
4
  /**
@@ -286,7 +286,7 @@ export class Page extends Component {
286
286
  * Get a URL for the current page with a different extension
287
287
  */
288
288
  variationUrl(extension) {
289
- return `${this.url.replace(/\.\w+$/, '')}.${extension}${printIf(this.url.startsWith('/.edit/'), `?token=${this.reqQuery.token ?? ''}`)}`;
289
+ return `${this.url.replace(/\.\w+$/, '')}.${extension}`;
290
290
  }
291
291
  passError(e, path) {
292
292
  console.warn(`Recoverable issue occured during render of ${this.pageInfo.path}. Component at ${path} threw the following error:`, e);
package/dist/links.js CHANGED
@@ -1,6 +1,15 @@
1
- import { htmlDecode } from 'txstate-utils';
2
- const LinkRegex = /{[^}]*"type"\s?:\s?"\w+"[^}]*}/g;
3
- const HTMLEscapedLinkRegex = /{[^}]*"type"\s?:\s?"\w+"[^}]*}/g;
1
+ import { htmlDecode, isNotNull } from 'txstate-utils';
2
+ const LinkRegex = /{[^{}]*"type"\s?:\s?"\w+"[^{}]*}/g;
3
+ const HTMLEscapedLinkRegex = /{[^{}]*"type"\s?:\s?"\w+"[^{}]*}/g;
4
+ function safeParse(json) {
5
+ try {
6
+ return JSON.parse(json);
7
+ }
8
+ catch (e) {
9
+ console.error(e, json);
10
+ return undefined;
11
+ }
12
+ }
4
13
  /**
5
14
  * This function is used by template definitions to help them identify links inside large blocks
6
15
  * of text and return them for indexing, and by render definitions to help replace them with the actual URLs.
@@ -9,13 +18,13 @@ const HTMLEscapedLinkRegex = /{[^}]*"type"\s?:\s?"\w+"[^}]*}
9
18
  export function extractLinksFromText(text) {
10
19
  if (!text)
11
20
  return [];
12
- const matches = Array.from(text.matchAll(LinkRegex)).map(m => JSON.parse(m[0]));
13
- const morematches = Array.from(text.matchAll(HTMLEscapedLinkRegex)).map(m => JSON.parse(htmlDecode(m[0])));
21
+ const matches = Array.from(text.matchAll(LinkRegex)).map(m => safeParse(m[0])).filter(isNotNull);
22
+ const morematches = Array.from(text.matchAll(HTMLEscapedLinkRegex)).map(m => safeParse(htmlDecode(m[0]))).filter(isNotNull);
14
23
  return matches.concat(morematches);
15
24
  }
16
25
  /**
17
26
  * This function is used by render definitions to replace `LinkDefinition` conformant link object text in large
18
27
  * blocks with the actual URLs they point to at render time. */
19
28
  export function replaceLinksInText(text, resolved) {
20
- return text.replace(LinkRegex, m => resolved.get(m) ?? 'dg-broken-link').replace(HTMLEscapedLinkRegex, m => resolved.get(htmlDecode(m)) ?? 'dg-broken-link');
29
+ return text.replace(LinkRegex, m => resolved.get(m) ?? safeParse(m)?.path ?? 'dg-broken-link').replace(HTMLEscapedLinkRegex, m => resolved.get(htmlDecode(m)) ?? safeParse(htmlDecode(m))?.path ?? 'dg-broken-link');
21
30
  }
@@ -121,6 +121,9 @@ export interface DialogPageProp {
121
121
  * API.
122
122
  */
123
123
  export declare function dialogQuery<T = any>(query: string, variables?: any): Promise<T>;
124
+ export interface TracingEnvironment {
125
+ tracingServer: string;
126
+ }
124
127
  /**
125
128
  * A type for the config object that should be exported from a CMS instance's admin/local/index.js
126
129
  * to configure how that instance should work.
@@ -185,10 +188,10 @@ export interface UIConfig {
185
188
  */
186
189
  assetMetaDialog?: UITemplate['dialog'];
187
190
  tracing?: {
188
- init?: () => void;
189
- startTransaction?: (name: string, details: any) => void;
190
- endTransaction?: (name: string, details: any) => void;
191
- event?: (name: string, details: any) => void;
191
+ init?: (env: TracingEnvironment) => void;
192
+ startTransaction?: (name: string, details: any, env: TracingEnvironment) => void;
193
+ endTransaction?: (name: string, details: any, env: TracingEnvironment) => void;
194
+ event?: (name: string, details: any, env: TracingEnvironment) => void;
192
195
  };
193
196
  }
194
197
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/templating",
3
- "version": "0.0.123",
3
+ "version": "0.0.125",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "type": "module",
6
6
  "exports": {