@appsemble/lang-sdk 0.40.4 → 0.40.5

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsemble/lang-sdk",
3
- "version": "0.40.4",
3
+ "version": "0.40.5",
4
4
  "description": "Language SDK for Appsemble",
5
5
  "keywords": [
6
6
  "app",
package/pageUtils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type MessageGetter } from './remap.js';
2
- import { type PageDefinition } from './types/index.js';
2
+ import { type PageDefinition, type Remapper } from './types/index.js';
3
3
  type NamedPage = Pick<PageDefinition, 'name'>;
4
4
  /**
5
5
  * The built-in routes whose URL segment an app may translate through a `routes.<Name>` message.
@@ -48,4 +48,11 @@ export declare function findPageById(pages: PageDefinition[], normalizedPageId:
48
48
  * @returns The ancestors, root first, excluding the page itself.
49
49
  */
50
50
  export declare function getPageAncestors(pages: PageDefinition[], page: PageDefinition, appMemberRoles?: string[]): PageDefinition[];
51
+ /**
52
+ * Check whether or not the given link represents a link related to the Appsemble core.
53
+ *
54
+ * @param link The link to check
55
+ * @returns Whether or not the given link represents a link related to the Appsemble core.
56
+ */
57
+ export declare function isAppLink(link: Remapper | string[] | string): link is `/${TranslatableRoute}`;
51
58
  export {};
package/pageUtils.js CHANGED
@@ -117,4 +117,13 @@ export function getPageAncestors(pages, page, appMemberRoles = []) {
117
117
  }
118
118
  return ancestors;
119
119
  }
120
+ /**
121
+ * Check whether or not the given link represents a link related to the Appsemble core.
122
+ *
123
+ * @param link The link to check
124
+ * @returns Whether or not the given link represents a link related to the Appsemble core.
125
+ */
126
+ export function isAppLink(link) {
127
+ return (link === '/Login' || link === '/Settings' || link === '/Register' || link === '/Reset-Password');
128
+ }
120
129
  //# sourceMappingURL=pageUtils.js.map
@@ -254,7 +254,10 @@ For example:
254
254
 
255
255
  For example:
256
256
 
257
- ${schemaExample('xml.parse', { result: 'pretty' })}`,
257
+ ${schemaExample('xml.parse', { result: 'pretty' })}
258
+
259
+ The tag and attribute names \`__proto__\`, \`constructor\` and \`prototype\` appear in the output
260
+ as \`#__proto__\`, \`#constructor\` and \`#prototype\`.`,
258
261
  $ref: '#/components/schemas/RemapperDefinition',
259
262
  },
260
263
  maths: {
package/remap.d.ts CHANGED
@@ -75,9 +75,7 @@ interface InternalContext extends RemapperContext {
75
75
  stepRef?: {
76
76
  current: Record<string, any>;
77
77
  };
78
- tabRef?: {
79
- current: Record<string, any>;
80
- };
78
+ tabName?: string;
81
79
  }
82
80
  export declare function remap(remapper: Remapper, input: unknown, context: InternalContext | RemapperContext): unknown;
83
81
  export {};
package/remap.js CHANGED
@@ -35,6 +35,21 @@ function isEqualObject(a, b) {
35
35
  function isNumber(a) {
36
36
  return a !== undefined && a != null && a !== '' && !Number.isNaN(Number(a));
37
37
  }
38
+ /**
39
+ * Tag and attribute names fast-xml-parser refuses to parse, because they could pollute object
40
+ * prototypes.
41
+ */
42
+ const prototypeNames = new Set(['__proto__', 'constructor', 'prototype']);
43
+ /**
44
+ * Prefix tag and attribute names that fast-xml-parser refuses with `#`, so the rest of the
45
+ * document still parses.
46
+ *
47
+ * @param name The XML tag or attribute name.
48
+ * @returns The name to use as the object key.
49
+ */
50
+ function escapePrototypeName(name) {
51
+ return prototypeNames.has(name) ? `#${name}` : name;
52
+ }
38
53
  export function remap(remapper, input, context) {
39
54
  if (typeof remapper === 'string' ||
40
55
  typeof remapper === 'number' ||
@@ -177,9 +192,7 @@ const mapperImplementations = {
177
192
  return context.stepRef.current[mapper];
178
193
  },
179
194
  'tab.name'(mapper, input, context) {
180
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
181
- // @ts-ignore 18048 variable is possibly undefined (strictNullChecks)
182
- return context.tabRef.current.name;
195
+ return context.tabName;
183
196
  },
184
197
  gt: ([left, right], input, context) =>
185
198
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -876,6 +889,8 @@ const mapperImplementations = {
876
889
  const parser = new XMLParser({
877
890
  ignoreAttributes: false,
878
891
  attributeNamePrefix: '',
892
+ transformAttributeName: escapePrototypeName,
893
+ transformTagName: escapePrototypeName,
879
894
  });
880
895
  try {
881
896
  return parser.parse(remap(value, input, context) || '');
package/validation.d.ts CHANGED
@@ -1,15 +1,7 @@
1
1
  import { type ValidatorResult } from 'jsonschema';
2
2
  import { type Promisable } from 'type-fest';
3
3
  import { type IdentifiableBlock } from './blockUtils.js';
4
- import { type TranslatableRoute } from './pageUtils.js';
5
- import { type AppDefinition, type BlockManifest, type ProjectImplementations, type Remapper } from './types/index.js';
6
- /**
7
- * Check whether or not the given link represents a link related to the Appsemble core.
8
- *
9
- * @param link The link to check
10
- * @returns Whether or not the given link represents a link related to the Appsemble core.
11
- */
12
- export declare function isAppLink(link: Remapper | string[] | string): link is `/${TranslatableRoute}`;
4
+ import { type AppDefinition, type BlockManifest, type ProjectImplementations } from './types/index.js';
13
5
  export type BlockVersionsGetter = (blockMap: IdentifiableBlock[]) => Promisable<BlockManifest[]>;
14
6
  /**
15
7
  * Validate an app definition.
package/validation.js CHANGED
@@ -6,6 +6,7 @@ import { BlockParamInstanceValidator } from './BasicValidator.js';
6
6
  import { getAppBlocks, normalizeBlockName } from './blockUtils.js';
7
7
  import { partialNormalized } from './constants/index.js';
8
8
  import { findPageByName } from './findPageByName.js';
9
+ import { isAppLink } from './pageUtils.js';
9
10
  import { bottomNavigationGridArea, breadcrumbsGridArea, builtinPagesGridAreaOrder, getBuiltinPagesDefaultGridLayout, getCascadedGridTemplateAreas, getGridTemplateAreas, gridDeviceOrder, resendBannerGridArea, } from './gridUtils.js';
10
11
  import { isValidIconName, parseIconReference } from './icons.js';
11
12
  import { iterAction, iterApp } from './iterApp.js';
@@ -44,15 +45,6 @@ function hasResourcePermission(permissions, resourceName, resourceAction, view)
44
45
  return false;
45
46
  });
46
47
  }
47
- /**
48
- * Check whether or not the given link represents a link related to the Appsemble core.
49
- *
50
- * @param link The link to check
51
- * @returns Whether or not the given link represents a link related to the Appsemble core.
52
- */
53
- export function isAppLink(link) {
54
- return (link === '/Login' || link === '/Settings' || link === '/Register' || link === '/Reset-Password');
55
- }
56
48
  function validateJSONSchema(schema, prefix, report) {
57
49
  if (schema.type !== 'object') {
58
50
  return;