Skip to content

Commit

Permalink
Merge branch 'master' into 118_variadic_distance_function
Browse files Browse the repository at this point in the history
  • Loading branch information
brontolosone committed Dec 17, 2024
2 parents 6661f8f + dfc6c70 commit b4a146a
Show file tree
Hide file tree
Showing 345 changed files with 14,764 additions and 3,922 deletions.
65 changes: 0 additions & 65 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -432,71 +432,6 @@ jobs:

- run: 'yarn workspace @getodk/tree-sitter-xpath test'

ui-solid:
name: '@getodk/ui-solid'
needs: ['install-and-build']
runs-on: 'ubuntu-latest'

strategy:
matrix:
target: ['Node']
node-version: ['18.20.4', '20.17.0', '22.9.0']
include:
- target: 'Web'
node-version: '22.9.0'
browser: chromium
- target: 'Web'
node-version: '22.9.0'
browser: firefox
- target: 'Web'
node-version: '22.9.0'
browser: webkit

steps:
- uses: 'actions/checkout@v4'

- uses: 'volta-cli/action@v4'
with:
node-version: '${{ matrix.node-version }}'
yarn-version: '1.22.22'

- uses: 'actions/cache@v4'
id: cache-install
with:
path: |
node_modules
**/node_modules
key: install-${{ matrix.node-version }}-${{ hashFiles('yarn.lock', '.github/workflows/ci.yml', 'examples/*/yarn.lock', 'packages/*/package.json', 'packages/*/yarn.lock') }}
fail-on-cache-miss: true

- uses: 'actions/cache@v4'
id: cache-build
with:
path: |
examples/*/dist
packages/*/dist
packages/web-forms/dist-demo
packages/tree-sitter-xpath/grammar.js
packages/tree-sitter-xpath/src/grammar.json
packages/tree-sitter-xpath/src/parser.c
packages/tree-sitter-xpath/src/tree_sitter/parser.h
packages/tree-sitter-xpath/tree-sitter-xpath.wasm
packages/tree-sitter-xpath/types
key: build-${{ matrix.node-version }}-${{ github.sha }}
fail-on-cache-miss: true

- if: ${{ matrix.target == 'Node' }}
run: 'yarn workspace @getodk/ui-solid test:types'

- if: ${{ matrix.target == 'Node' }}
run: 'yarn workspace @getodk/ui-solid test-node:jsdom'

- if: ${{ matrix.target == 'Web' }}
run: 'yarn playwright install ${{ matrix.browser }} --with-deps'

- if: ${{ matrix.target == 'Web' }}
run: 'yarn workspace @getodk/ui-solid test-browser:${{ matrix.browser }}'

web-forms:
name: '@getodk/web-forms'
needs: ['install-and-build']
Expand Down
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export default tseslint.config(
'packages/tree-sitter-xpath/grammar.js',
'packages/tree-sitter-xpath/bindings/**/*',
'packages/tree-sitter-xpath/types/**/*',
'packages/ui-solid/**/*',
'packages/web-forms/dist-demo/**/*',
'packages/xforms-engine/api-docs/**/*',
'**/vendor',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@types/eslint": "^9.6.1",
"@types/eslint-config-prettier": "^6.11.3",
"@types/eslint__js": "^8.42.3",
"@types/geojson": "^7946.0.14",
"@types/jsdom": "^21.1.7",
"@types/node": "^22.7.2",
"@typescript-eslint/eslint-plugin": "^8.7.0",
Expand Down
11 changes: 11 additions & 0 deletions packages/common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @getodk/common

## 0.5.0

### Minor Changes

- 2fddcec: Support for external secondary instances (XML, CSV, GeoJSON)

### Patch Changes

- e636a9c: XPath support for evaluation of arbitrary DOM implementations (XPathDOMAdapter)
- 8edf375: Initial engine support for preparing submissions

## 0.4.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@getodk/common",
"private": true,
"version": "0.4.0",
"version": "0.5.0",
"description": "@getodk/common",
"type": "module",
"author": "getodk",
Expand Down
41 changes: 38 additions & 3 deletions packages/common/src/constants/xmlns.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,66 @@
// Native/common standards
export const XHTML_NAMESPACE_URI = 'http://www.w3.org/1999/xhtml';
export type XHTML_NAMESPACE_URI = typeof XHTML_NAMESPACE_URI;

export const HTML_NAMESPACE_URI = XHTML_NAMESPACE_URI;
export type HTML_NAMESPACE_URI = typeof HTML_NAMESPACE_URI;

export const XML_NAMESPACE_URI = 'http://www.w3.org/XML/1998/namespace';
export type XML_NAMESPACE_URI = typeof XML_NAMESPACE_URI;

export const XMLNS_NAMESPACE_URI = 'http://www.w3.org/2000/xmlns/';
export type XMLNS_NAMESPACE_URI = typeof XMLNS_NAMESPACE_URI;

export const XSD_NAMESPACE_URI = 'http://www.w3.org/2001/XMLSchema';
export type XSD_NAMESPACE_URI = typeof XSD_NAMESPACE_URI;

export const FN_NAMESPACE_URI = 'http://www.w3.org/2005/xpath-functions';
export type FN_NAMESPACE_URI = typeof FN_NAMESPACE_URI;

// XForms/ODK
export const JAVAROSA_NAMESPACE_URI = 'http://openrosa.org/javarosa';
export type JAVAROSA_NAMESPACE_URI = typeof JAVAROSA_NAMESPACE_URI;

export const ODK_NAMESPACE_URI = 'http://www.opendatakit.org/xforms';
export type ODK_NAMESPACE_URI = typeof ODK_NAMESPACE_URI;

export const OPENROSA_XFORMS_NAMESPACE_URI = 'http://openrosa.org/xforms';
export const XFORMS_NAMESPACE_URI = 'http://www.w3.org/2002/xforms';
export type OPENROSA_XFORMS_NAMESPACE_URI = typeof OPENROSA_XFORMS_NAMESPACE_URI;

export type JavaRosaNamespaceURI = typeof JAVAROSA_NAMESPACE_URI;
export type XFormsNamespaceURI = typeof XFORMS_NAMESPACE_URI;
export const XFORMS_NAMESPACE_URI = 'http://www.w3.org/2002/xforms';
export type XFORMS_NAMESPACE_URI = typeof XFORMS_NAMESPACE_URI;

// Enketo
export const ENKETO_NAMESPACE_URI = 'http://enketo.org/xforms';
export type ENKETO_NAMESPACE_URI = typeof ENKETO_NAMESPACE_URI;

// Default prefixes
export const HTML_PREFIX = 'h';
export type HTML_PREFIX = typeof HTML_PREFIX;

export const XML_PREFIX = 'xml';
export type XML_PREFIX = typeof XML_PREFIX;

export const XMLNS_PREFIX = 'xmlns';
export type XMLNS_PREFIX = typeof XMLNS_PREFIX;

export const XSD_PREFIX = 'xsd';
export type XSD_PREFIX = typeof XSD_PREFIX;

export const FN_PREFIX = 'fn';
export type FN_PREFIX = typeof FN_PREFIX;

export const JAVAROSA_PREFIX = 'jr';
export type JAVAROSA_PREFIX = typeof JAVAROSA_PREFIX;

export const ODK_PREFIX = 'odk';
export type ODK_PREFIX = typeof ODK_PREFIX;

export const OPENROSA_XFORMS_PREFIX = 'orx';
export type OPENROSA_XFORMS_PREFIX = typeof OPENROSA_XFORMS_PREFIX;

export const XFORMS_PREFIX = 'xf';
export type XFORMS_PREFIX = typeof XFORMS_PREFIX;

export const ENKETO_PREFIX = 'enk';
export type ENKETO_PREFIX = typeof ENKETO_PREFIX;
70 changes: 70 additions & 0 deletions packages/common/src/fixtures/import-glob-helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { IS_NODE_RUNTIME } from '../env/detection.ts';

interface GlobURLFetchResponse {
text(): Promise<string>;
}

type Awaitable<T> = Promise<T> | T;

type FetchGlobURL = (globURL: string) => Awaitable<GlobURLFetchResponse>;

let fetchGlobURL: FetchGlobURL;

if (IS_NODE_RUNTIME) {
const { readFile } = await import('node:fs/promises');

class NodeGlobURLFetchResponse {
readonly fsPath: string;

constructor(globURL: string) {
this.fsPath = globURL.replace('/@fs/', '/');
}

text(): Promise<string> {
return readFile(this.fsPath, 'utf-8');
}
}

fetchGlobURL = (globURL) => {
return new NodeGlobURLFetchResponse(globURL);
};
} else {
fetchGlobURL = fetch;
}

type ImportMetaGlobURLRecord = Readonly<Record<string, string>>;

export type GlobFixtureLoader = (this: void) => Promise<string>;

export interface GlobFixture {
readonly url: URL;
readonly load: GlobFixtureLoader;
}

export type GlobFixtureEntry = readonly [absolutePath: string, loader: GlobFixture];

const globFixtureLoader = (globURL: string): GlobFixtureLoader => {
return async () => {
const response = await fetchGlobURL(globURL);

return response.text();
};
};

export const toGlobLoaderEntries = (
importMeta: ImportMeta,
globObject: ImportMetaGlobURLRecord
): readonly GlobFixtureEntry[] => {
const parentPathURL = new URL('./', importMeta.url);

return Object.entries(globObject).map(([relativePath, value]) => {
const { pathname: absolutePath } = new URL(relativePath, parentPathURL);
const fixtureAssetURL = new URL(value, import.meta.url);
const fixture: GlobFixture = {
url: fixtureAssetURL,
load: globFixtureLoader(value),
};

return [absolutePath, fixture];
});
};
3 changes: 3 additions & 0 deletions packages/common/src/fixtures/test-scenario/csv-attachment.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
item-label,item-value
Y,y
Z,z
10 changes: 10 additions & 0 deletions packages/common/src/fixtures/test-scenario/xml-attachment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<instance-root>
<instance-item>
<item-label>A</item-label>
<item-value>a</item-value>
</instance-item>
<instance-item>
<item-label>B</item-label>
<item-value>b</item-value>
</instance-item>
</instance-root>
69 changes: 69 additions & 0 deletions packages/common/src/fixtures/value-types/numeric-value-types.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:jr="http://openrosa.org/javarosa"
xmlns:orx="http://openrosa.org/xforms/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>Value types (numeric)</h:title>
<model>
<instance>
<root id="value-types-numeric">
<int-q>1</int-q>
<int-val />
<decimal-q>1.5</decimal-q>
<decimal-val />
<numbers-q>95</numbers-q>
<numbers-val />
<thousands-int></thousands-int>
<thousands-decimal></thousands-decimal>
<thousands-numbers></thousands-numbers>
<thousands-q>9999</thousands-q>
<meta>
<instanceID />
</meta>
</root>
</instance>
<bind nodeset="/root/int-q" type="int" constraint=". &gt; 1" />
<bind nodeset="/root/int-val" calculate="/root/int-q" readonly="true()" />
<bind nodeset="/root/decimal-q" type="decimal" constraint=". &lt; 2.5" />
<bind nodeset="/root/decimal-val" calculate="/root/decimal-q" readonly="true()" />
<bind nodeset="/root/numbers-q" type="string" constraint=". &gt; 94.99" />
<bind nodeset="/root/numbers-val" calculate="/root/numbers-q" readonly="true()" />
<bind nodeset="/root/thousands-int" type="int" />
<bind nodeset="/root/thousands-decimal" type="decimal" />
<bind nodeset="/root/thousands-numbers" type="string" />
<bind nodeset="/root/meta/instanceID" type="string" />
</model>
</h:head>
<h:body>
<input ref="/root/int-q">
<label>1. Int[eger] question</label>
</input>
<input ref="/root/int-val">
<label>1.1 Int value</label>
</input>
<input ref="/root/decimal-q">
<label>2. Decimal question</label>
</input>
<input ref="/root/decimal-val">
<label>2.1 Decimal value</label>
</input>
<input ref="/root/numbers-q" appearance="numbers">
<label>3. Numbers question (string + appearance="numbers")</label>
</input>
<input ref="/root/numbers-val">
<label>3.1 Numbers value</label>
</input>
<input ref="/root/thousands-int" appearance="thousands-sep">
<label>4. Thousands separator (type="int")</label>
</input>
<input ref="/root/thousands-decimal" appearance="thousands-sep">
<label>4. Thousands separator (type="decimal")</label>
</input>
<input ref="/root/thousands-numbers" appearance="numbers thousands-sep">
<label>4. Thousands separator (string + appearance="numbers thousands-sep")</label>
</input>
</h:body>
</h:html>
Loading

0 comments on commit b4a146a

Please sign in to comment.