@pod-os/elements 0.0.1 → 0.0.2

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.
Files changed (36) hide show
  1. package/dist/cjs/elements.cjs.js +1 -1
  2. package/dist/cjs/{ion-app_32.cjs.entry.js → ion-app_33.cjs.entry.js} +424 -41
  3. package/dist/cjs/ion-card-subtitle.cjs.entry.js +30 -0
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/collection/apps/pos-app-generic/pos-app-generic.js +20 -0
  6. package/dist/collection/collection-manifest.json +3 -1
  7. package/dist/collection/components/pos-app/pos-app.js +6 -6
  8. package/dist/collection/components/pos-demo-app/pos-demo-app.js +3 -34
  9. package/dist/collection/components/pos-login/pos-login.js +7 -7
  10. package/dist/collection/components/pos-resource/pos-resource.js +6 -3
  11. package/dist/collection/components/pos-rich-link/pos-rich-link.js +1 -1
  12. package/dist/collection/components/pos-router/pos-router.js +38 -0
  13. package/dist/collection/store/session.js +2 -2
  14. package/dist/collection/test/mockPodOS.js +15 -1
  15. package/dist/custom-elements/index.d.ts +12 -0
  16. package/dist/custom-elements/index.js +439 -27
  17. package/dist/elements/elements.esm.js +1 -1
  18. package/dist/elements/p-30c47b84.entry.js +1 -0
  19. package/dist/elements/p-7d1985a3.entry.js +1 -0
  20. package/dist/esm/elements.js +1 -1
  21. package/dist/esm/{ion-app_32.entry.js → ion-app_33.entry.js} +421 -39
  22. package/dist/esm/ion-card-subtitle.entry.js +26 -0
  23. package/dist/esm/loader.js +1 -1
  24. package/dist/types/apps/pos-app-generic/pos-app-generic.d.ts +3 -0
  25. package/dist/types/components/pos-app/pos-app.d.ts +2 -2
  26. package/dist/types/components/pos-demo-app/pos-demo-app.d.ts +0 -2
  27. package/dist/types/components/pos-login/pos-login.d.ts +1 -1
  28. package/dist/types/components/pos-resource/pos-resource.d.ts +1 -1
  29. package/dist/types/components/pos-rich-link/pos-rich-link.d.ts +1 -1
  30. package/dist/types/components/pos-router/pos-router.d.ts +8 -0
  31. package/dist/types/components.d.ts +28 -2
  32. package/dist/types/store/session.d.ts +3 -3
  33. package/dist/types/test/mockPodOS.d.ts +1 -0
  34. package/package.json +13 -4
  35. package/readme.md +9 -64
  36. package/dist/elements/p-64fbf059.entry.js +0 -1
@@ -13531,7 +13531,7 @@ const removeRipple = (ripple) => {
13531
13531
  const PADDING = 10;
13532
13532
  const INITIAL_ORIGIN_SCALE = 0.5;
13533
13533
 
13534
- const Route = class extends HTMLElement {
13534
+ const Route$1 = class extends HTMLElement {
13535
13535
  constructor() {
13536
13536
  super();
13537
13537
  this.__registerHost();
@@ -13999,7 +13999,7 @@ const flattenNode = (chain, chains, node) => {
13999
13999
  }
14000
14000
  };
14001
14001
 
14002
- const Router = class extends HTMLElement {
14002
+ const Router$1 = class extends HTMLElement {
14003
14003
  constructor() {
14004
14004
  super();
14005
14005
  this.__registerHost();
@@ -18339,7 +18339,7 @@ const createStore = (defaultState, shouldUpdate) => {
18339
18339
 
18340
18340
  const getIdpUrl = () => prompt('Please enter your Identity Provider URL', 'http://localhost:3000');
18341
18341
 
18342
- const { state } = createStore({
18342
+ const store = createStore({
18343
18343
  getIdpUrl,
18344
18344
  isLoggedIn: false,
18345
18345
  webId: '',
@@ -18359,11 +18359,11 @@ const PosApp$1 = class extends HTMLElement {
18359
18359
  this.os = createPodOS();
18360
18360
  this.os.handleIncomingRedirect();
18361
18361
  this.os.trackSession(sessionInfo => {
18362
- state.isLoggedIn = sessionInfo.isLoggedIn;
18363
- state.webId = sessionInfo.webId;
18362
+ store.state.isLoggedIn = sessionInfo.isLoggedIn;
18363
+ store.state.webId = sessionInfo.webId;
18364
18364
  });
18365
18365
  }
18366
- async consumeOs(event) {
18366
+ async initializeOs(event) {
18367
18367
  event.stopPropagation();
18368
18368
  event.detail(this.os);
18369
18369
  }
@@ -18372,17 +18372,23 @@ const PosApp$1 = class extends HTMLElement {
18372
18372
  }
18373
18373
  };
18374
18374
 
18375
- const PosDemoApp$1 = class extends HTMLElement {
18375
+ const PosAppGeneric$1 = class extends HTMLElement {
18376
18376
  constructor() {
18377
18377
  super();
18378
18378
  this.__registerHost();
18379
- this.url = 'http://localhost:3000/alice/games/minecraft#it';
18380
18379
  }
18381
- linkClicked(e) {
18382
- this.url = e.detail;
18380
+ render() {
18381
+ return (h("ion-grid", null, h("ion-row", null, h("ion-col", { size: "12", "size-sm": true }, h("ion-card", null, h("ion-card-header", null, h("img", { src: "https://dummyimage.com/250/ffffff/000000" }), h("ion-card-title", null, h("pos-label", null))), h("ion-card-content", null, h("pos-description", null)))), h("ion-col", { size: "12", "size-sm": true }, h("pos-literals", null)), h("ion-col", { size: "12", "size-sm": true }, h("pos-relations", null)))));
18382
+ }
18383
+ };
18384
+
18385
+ const PosDemoApp$1 = class extends HTMLElement {
18386
+ constructor() {
18387
+ super();
18388
+ this.__registerHost();
18383
18389
  }
18384
18390
  render() {
18385
- return (h("pos-app", null, h("ion-header", null, h("ion-toolbar", null, h("ion-title", { slot: "start" }, "pod os"), h("pos-login", null))), h("ion-content", { class: "ion-padding" }, h("pos-resource", { uri: this.url }, h("ion-grid", null, h("ion-row", null, h("ion-col", { size: "12", "size-sm": true }, h("ion-card", null, h("ion-card-header", null, h("img", { src: "https://upload.wikimedia.org/wikipedia/de/5/57/Minecraft_logo-SVG.svg" }), h("ion-card-subtitle", null, "VideoGame"), h("ion-card-title", null, h("pos-label", null))), h("ion-card-content", null, h("pos-description", null)))), h("ion-col", { size: "12", "size-sm": true }, h("pos-literals", null)), h("ion-col", { size: "12", "size-sm": true }, h("pos-relations", null)))))), h("ion-footer", null, h("ion-toolbar", null, h("ion-title", null, "Footer")))));
18391
+ return (h("pos-app", null, h("ion-header", null, h("ion-toolbar", null, h("ion-title", { slot: "start" }, "pod os"), h("pos-login", null))), h("ion-content", null, h("pos-router", null)), h("ion-footer", null, h("ion-toolbar", null, h("ion-title", null, "Footer")))));
18386
18392
  }
18387
18393
  };
18388
18394
 
@@ -18404,7 +18410,7 @@ const PosDescription$1 = class extends HTMLElement {
18404
18410
  }
18405
18411
  };
18406
18412
 
18407
- const PosLabel$2 = class extends HTMLElement {
18413
+ const PosLabel$1 = class extends HTMLElement {
18408
18414
  constructor() {
18409
18415
  super();
18410
18416
  this.__registerHost();
@@ -18446,23 +18452,23 @@ const PosLogin$1 = class extends HTMLElement {
18446
18452
  constructor() {
18447
18453
  super();
18448
18454
  this.__registerHost();
18449
- this.consumeOsEmitter = createEvent(this, "consumeOs", 7);
18455
+ this.initializeOsEmitter = createEvent(this, "pod-os:init", 7);
18450
18456
  this.setOs = async (os) => {
18451
18457
  this.os = os;
18452
18458
  };
18453
18459
  }
18454
18460
  componentWillLoad() {
18455
- this.consumeOsEmitter.emit(this.setOs);
18461
+ this.initializeOsEmitter.emit(this.setOs);
18456
18462
  }
18457
18463
  login() {
18458
- const idp = state.getIdpUrl();
18464
+ const idp = store.state.getIdpUrl();
18459
18465
  this.os.login(idp);
18460
18466
  }
18461
18467
  logout() {
18462
18468
  this.os.logout();
18463
18469
  }
18464
18470
  render() {
18465
- return (h(Host, null, state.isLoggedIn ? (h("pos-resource", { uri: state.webId }, h("pos-label", null))) : (''), !state.isLoggedIn && h("ion-button", { onClick: () => this.login() }, "Login"), state.isLoggedIn && h("ion-button", { onClick: () => this.logout() }, "Logout")));
18471
+ return (h(Host, null, store.state.isLoggedIn ? (h("pos-resource", { uri: store.state.webId }, h("pos-label", null))) : (''), !store.state.isLoggedIn && h("ion-button", { onClick: () => this.login() }, "Login"), store.state.isLoggedIn && h("ion-button", { onClick: () => this.logout() }, "Logout")));
18466
18472
  }
18467
18473
  };
18468
18474
 
@@ -18491,7 +18497,7 @@ const PosResource$1 = class extends HTMLElement {
18491
18497
  super();
18492
18498
  this.__registerHost();
18493
18499
  attachShadow(this);
18494
- this.consumeOsEmitter = createEvent(this, "consumeOs", 7);
18500
+ this.initializeOsEmitter = createEvent(this, "pod-os:init", 7);
18495
18501
  this.consumers = [];
18496
18502
  this.lazy = false;
18497
18503
  this.loading = true;
@@ -18500,7 +18506,8 @@ const PosResource$1 = class extends HTMLElement {
18500
18506
  };
18501
18507
  }
18502
18508
  componentWillLoad() {
18503
- this.consumeOsEmitter.emit(this.setOs);
18509
+ store.onChange('isLoggedIn', () => this.loadResource());
18510
+ this.initializeOsEmitter.emit(this.setOs);
18504
18511
  }
18505
18512
  async provideResource(event) {
18506
18513
  event.stopPropagation();
@@ -18522,6 +18529,7 @@ const PosResource$1 = class extends HTMLElement {
18522
18529
  await this.os.fetch(this.uri);
18523
18530
  }
18524
18531
  this.resource = this.os.store.get(this.uri);
18532
+ this.error = null;
18525
18533
  this.consumers.forEach(consumer => {
18526
18534
  consumer.detail(this.resource);
18527
18535
  });
@@ -18548,7 +18556,7 @@ const PosResource$1 = class extends HTMLElement {
18548
18556
  }; }
18549
18557
  };
18550
18558
 
18551
- const PosLabel$1 = class extends HTMLElement {
18559
+ const PosRichLink$1 = class extends HTMLElement {
18552
18560
  constructor() {
18553
18561
  super();
18554
18562
  this.__registerHost();
@@ -18563,6 +18571,406 @@ const PosLabel$1 = class extends HTMLElement {
18563
18571
  }
18564
18572
  };
18565
18573
 
18574
+ const createRouter = (opts) => {
18575
+ var _a;
18576
+ const win = window;
18577
+ const url = new URL(win.location.href);
18578
+ const parseURL = (_a = opts === null || opts === void 0 ? void 0 : opts.parseURL) !== null && _a !== void 0 ? _a : DEFAULT_PARSE_URL;
18579
+ const { state, onChange, dispose } = createStore({
18580
+ url,
18581
+ activePath: parseURL(url)
18582
+ }, (newV, oldV, prop) => {
18583
+ if (prop === 'url') {
18584
+ return newV.href !== oldV.href;
18585
+ }
18586
+ return newV !== oldV;
18587
+ });
18588
+ const push = (href) => {
18589
+ history.pushState(null, null, href);
18590
+ const url = new URL(href, document.baseURI);
18591
+ state.url = url;
18592
+ state.activePath = parseURL(url);
18593
+ };
18594
+ const match = (routes) => {
18595
+ const { activePath } = state;
18596
+ for (let route of routes) {
18597
+ const params = matchPath(activePath, route.path);
18598
+ if (params) {
18599
+ if (route.to != null) {
18600
+ const to = (typeof route.to === 'string')
18601
+ ? route.to
18602
+ : route.to(activePath);
18603
+ push(to);
18604
+ return match(routes);
18605
+ }
18606
+ else {
18607
+ return { params, route };
18608
+ }
18609
+ }
18610
+ }
18611
+ return undefined;
18612
+ };
18613
+ const navigationChanged = () => {
18614
+ const url = new URL(win.location.href);
18615
+ state.url = url;
18616
+ state.activePath = parseURL(url);
18617
+ };
18618
+ const Switch = (_, childrenRoutes) => {
18619
+ const result = match(childrenRoutes);
18620
+ if (result) {
18621
+ if (typeof result.route.jsx === 'function') {
18622
+ return result.route.jsx(result.params);
18623
+ }
18624
+ else {
18625
+ return result.route.jsx;
18626
+ }
18627
+ }
18628
+ };
18629
+ const disposeRouter = () => {
18630
+ win.removeEventListener('popstate', navigationChanged);
18631
+ dispose();
18632
+ };
18633
+ const router = {
18634
+ Switch,
18635
+ get url() {
18636
+ return state.url;
18637
+ },
18638
+ get activePath() {
18639
+ return state.activePath;
18640
+ },
18641
+ push,
18642
+ onChange: onChange,
18643
+ dispose: disposeRouter,
18644
+ };
18645
+ // Initial update
18646
+ navigationChanged();
18647
+ // Listen URL changes
18648
+ win.addEventListener('popstate', navigationChanged);
18649
+ return router;
18650
+ };
18651
+ const Route = (props, children) => {
18652
+ var _a;
18653
+ if ('to' in props) {
18654
+ return {
18655
+ path: props.path,
18656
+ to: props.to,
18657
+ };
18658
+ }
18659
+ if (Build.isDev && props.render && children.length > 0) {
18660
+ console.warn('Route: if `render` is provided, the component should not have any children');
18661
+ }
18662
+ return {
18663
+ path: props.path,
18664
+ id: props.id,
18665
+ jsx: (_a = props.render) !== null && _a !== void 0 ? _a : children,
18666
+ };
18667
+ };
18668
+ const matchPath = (pathname, path) => {
18669
+ if (typeof path === 'string') {
18670
+ if (path === pathname) {
18671
+ return {};
18672
+ }
18673
+ }
18674
+ else if (typeof path === 'function') {
18675
+ const params = path(pathname);
18676
+ if (params) {
18677
+ return params === true
18678
+ ? {}
18679
+ : { ...params };
18680
+ }
18681
+ }
18682
+ else {
18683
+ const results = path.exec(pathname);
18684
+ if (results) {
18685
+ path.lastIndex = 0;
18686
+ return { ...results };
18687
+ }
18688
+ }
18689
+ return undefined;
18690
+ };
18691
+ const DEFAULT_PARSE_URL = (url) => {
18692
+ return url.pathname.toLowerCase();
18693
+ };
18694
+
18695
+ /**
18696
+ * TS adaption of https://github.com/pillarjs/path-to-regexp/blob/master/index.js
18697
+ */
18698
+ /**
18699
+ * Default configs.
18700
+ */
18701
+ const DEFAULT_DELIMITER = '/';
18702
+ const DEFAULT_DELIMITERS = './';
18703
+ /**
18704
+ * The main path matching regexp utility.
18705
+ */
18706
+ const PATH_REGEXP = new RegExp([
18707
+ // Match escaped characters that would otherwise appear in future matches.
18708
+ // This allows the user to escape special characters that won't transform.
18709
+ '(\\\\.)',
18710
+ // Match Express-style parameters and un-named parameters with a prefix
18711
+ // and optional suffixes. Matches appear as:
18712
+ //
18713
+ // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?"]
18714
+ // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined]
18715
+ '(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?'
18716
+ ].join('|'), 'g');
18717
+ /**
18718
+ * Parse a string for the raw tokens.
18719
+ */
18720
+ const parse = (str, options) => {
18721
+ var tokens = [];
18722
+ var key = 0;
18723
+ var index = 0;
18724
+ var path = '';
18725
+ var defaultDelimiter = (options && options.delimiter) || DEFAULT_DELIMITER;
18726
+ var delimiters = (options && options.delimiters) || DEFAULT_DELIMITERS;
18727
+ var pathEscaped = false;
18728
+ var res;
18729
+ while ((res = PATH_REGEXP.exec(str)) !== null) {
18730
+ var m = res[0];
18731
+ var escaped = res[1];
18732
+ var offset = res.index;
18733
+ path += str.slice(index, offset);
18734
+ index = offset + m.length;
18735
+ // Ignore already escaped sequences.
18736
+ if (escaped) {
18737
+ path += escaped[1];
18738
+ pathEscaped = true;
18739
+ continue;
18740
+ }
18741
+ var prev = '';
18742
+ var next = str[index];
18743
+ var name = res[2];
18744
+ var capture = res[3];
18745
+ var group = res[4];
18746
+ var modifier = res[5];
18747
+ if (!pathEscaped && path.length) {
18748
+ var k = path.length - 1;
18749
+ if (delimiters.indexOf(path[k]) > -1) {
18750
+ prev = path[k];
18751
+ path = path.slice(0, k);
18752
+ }
18753
+ }
18754
+ // Push the current path onto the tokens.
18755
+ if (path) {
18756
+ tokens.push(path);
18757
+ path = '';
18758
+ pathEscaped = false;
18759
+ }
18760
+ var partial = prev !== '' && next !== undefined && next !== prev;
18761
+ var repeat = modifier === '+' || modifier === '*';
18762
+ var optional = modifier === '?' || modifier === '*';
18763
+ var delimiter = prev || defaultDelimiter;
18764
+ var pattern = capture || group;
18765
+ tokens.push({
18766
+ name: name || key++,
18767
+ prefix: prev,
18768
+ delimiter: delimiter,
18769
+ optional: optional,
18770
+ repeat: repeat,
18771
+ partial: partial,
18772
+ pattern: pattern ? escapeGroup(pattern) : '[^' + escapeString(delimiter) + ']+?'
18773
+ });
18774
+ }
18775
+ // Push any remaining characters.
18776
+ if (path || index < str.length) {
18777
+ tokens.push(path + str.substr(index));
18778
+ }
18779
+ return tokens;
18780
+ };
18781
+ /**
18782
+ * Escape a regular expression string.
18783
+ */
18784
+ const escapeString = (str) => {
18785
+ return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, '\\$1');
18786
+ };
18787
+ /**
18788
+ * Escape the capturing group by escaping special characters and meaning.
18789
+ */
18790
+ const escapeGroup = (group) => {
18791
+ return group.replace(/([=!:$/()])/g, '\\$1');
18792
+ };
18793
+ /**
18794
+ * Get the flags for a regexp from the options.
18795
+ */
18796
+ const flags = (options) => {
18797
+ return options && options.sensitive ? '' : 'i';
18798
+ };
18799
+ /**
18800
+ * Pull out keys from a regexp.
18801
+ */
18802
+ const regexpToRegexp = (path, keys) => {
18803
+ if (!keys)
18804
+ return path;
18805
+ // Use a negative lookahead to match only capturing groups.
18806
+ var groups = path.source.match(/\((?!\?)/g);
18807
+ if (groups) {
18808
+ for (var i = 0; i < groups.length; i++) {
18809
+ keys.push({
18810
+ name: i,
18811
+ prefix: null,
18812
+ delimiter: null,
18813
+ optional: false,
18814
+ repeat: false,
18815
+ partial: false,
18816
+ pattern: null
18817
+ });
18818
+ }
18819
+ }
18820
+ return path;
18821
+ };
18822
+ /**
18823
+ * Transform an array into a regexp.
18824
+ */
18825
+ const arrayToRegexp = (path, keys, options) => {
18826
+ var parts = [];
18827
+ for (var i = 0; i < path.length; i++) {
18828
+ parts.push(pathToRegexp(path[i], keys, options).source);
18829
+ }
18830
+ return new RegExp('(?:' + parts.join('|') + ')', flags(options));
18831
+ };
18832
+ /**
18833
+ * Create a path regexp from string input.
18834
+ */
18835
+ const stringToRegexp = (path, keys, options) => {
18836
+ return tokensToRegExp(parse(path, options), keys, options);
18837
+ };
18838
+ /**
18839
+ * Expose a function for taking tokens and returning a RegExp.
18840
+ */
18841
+ const tokensToRegExp = (tokens, keys, options) => {
18842
+ options = options || {};
18843
+ var strict = options.strict;
18844
+ var end = options.end !== false;
18845
+ var delimiter = escapeString(options.delimiter || DEFAULT_DELIMITER);
18846
+ var delimiters = options.delimiters || DEFAULT_DELIMITERS;
18847
+ var endsWith = [].concat(options.endsWith || []).map(escapeString).concat('$').join('|');
18848
+ var route = '';
18849
+ var isEndDelimited = false;
18850
+ // Iterate over the tokens and create our regexp string.
18851
+ for (var i = 0; i < tokens.length; i++) {
18852
+ var token = tokens[i];
18853
+ if (typeof token === 'string') {
18854
+ route += escapeString(token);
18855
+ isEndDelimited = i === tokens.length - 1 && delimiters.indexOf(token[token.length - 1]) > -1;
18856
+ }
18857
+ else {
18858
+ var prefix = escapeString(token.prefix || '');
18859
+ var capture = token.repeat
18860
+ ? '(?:' + token.pattern + ')(?:' + prefix + '(?:' + token.pattern + '))*'
18861
+ : token.pattern;
18862
+ if (keys)
18863
+ keys.push(token);
18864
+ if (token.optional) {
18865
+ if (token.partial) {
18866
+ route += prefix + '(' + capture + ')?';
18867
+ }
18868
+ else {
18869
+ route += '(?:' + prefix + '(' + capture + '))?';
18870
+ }
18871
+ }
18872
+ else {
18873
+ route += prefix + '(' + capture + ')';
18874
+ }
18875
+ }
18876
+ }
18877
+ if (end) {
18878
+ if (!strict)
18879
+ route += '(?:' + delimiter + ')?';
18880
+ route += endsWith === '$' ? '$' : '(?=' + endsWith + ')';
18881
+ }
18882
+ else {
18883
+ if (!strict)
18884
+ route += '(?:' + delimiter + '(?=' + endsWith + '))?';
18885
+ if (!isEndDelimited)
18886
+ route += '(?=' + delimiter + '|' + endsWith + ')';
18887
+ }
18888
+ return new RegExp('^' + route, flags(options));
18889
+ };
18890
+ /**
18891
+ * Normalize the given path string, returning a regular expression.
18892
+ *
18893
+ * An empty array can be passed in for the keys, which will hold the
18894
+ * placeholder key descriptions. For example, using `/user/:id`, `keys` will
18895
+ * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
18896
+ */
18897
+ const pathToRegexp = (path, keys, options) => {
18898
+ if (path instanceof RegExp) {
18899
+ return regexpToRegexp(path, keys);
18900
+ }
18901
+ if (Array.isArray(path)) {
18902
+ return arrayToRegexp(path, keys, options);
18903
+ }
18904
+ return stringToRegexp(path, keys, options);
18905
+ };
18906
+
18907
+ let cacheCount = 0;
18908
+ const patternCache = {};
18909
+ const cacheLimit = 10000;
18910
+ // Memoized function for creating the path match regex
18911
+ const compilePath = (pattern, options) => {
18912
+ const cacheKey = `${options.end}${options.strict}`;
18913
+ const cache = patternCache[cacheKey] || (patternCache[cacheKey] = {});
18914
+ const cachePattern = JSON.stringify(pattern);
18915
+ if (cache[cachePattern]) {
18916
+ return cache[cachePattern];
18917
+ }
18918
+ const keys = [];
18919
+ const re = pathToRegexp(pattern, keys, options);
18920
+ const compiledPattern = { re, keys };
18921
+ if (cacheCount < cacheLimit) {
18922
+ cache[cachePattern] = compiledPattern;
18923
+ cacheCount += 1;
18924
+ }
18925
+ return compiledPattern;
18926
+ };
18927
+ const match = (pathname, options = {}) => {
18928
+ const { exact = false, strict = false } = options;
18929
+ const { re, keys } = compilePath(pathname, { end: exact, strict });
18930
+ return (path) => {
18931
+ const match = re.exec(path);
18932
+ if (!match) {
18933
+ return undefined;
18934
+ }
18935
+ const [url, ...values] = match;
18936
+ const isExact = path === url;
18937
+ if (exact && !isExact) {
18938
+ return undefined;
18939
+ }
18940
+ return keys.reduce((memo, key, index) => {
18941
+ memo[key.name] = values[index];
18942
+ return memo;
18943
+ }, {});
18944
+ };
18945
+ };
18946
+
18947
+ const Router = createRouter();
18948
+ const PosRouter$1 = class extends HTMLElement {
18949
+ constructor() {
18950
+ super();
18951
+ this.__registerHost();
18952
+ }
18953
+ linkClicked(e) {
18954
+ this.navigate(e.detail);
18955
+ }
18956
+ componentWillLoad() {
18957
+ this.updateUri();
18958
+ Router.onChange('url', () => {
18959
+ this.updateUri();
18960
+ });
18961
+ }
18962
+ navigate(uri) {
18963
+ Router.push('?uri=' + encodeURIComponent(uri));
18964
+ }
18965
+ updateUri() {
18966
+ this.uri = new URLSearchParams(window.location.search).get('uri') || window.location.href;
18967
+ }
18968
+ render() {
18969
+ console.log('render router', this.uri);
18970
+ return (h(Router.Switch, null, h(Route, { path: match('', { exact: false }) }, h("pos-resource", { key: this.uri, uri: this.uri }, h("pos-app-generic", null)))));
18971
+ }
18972
+ };
18973
+
18566
18974
  globalScripts();
18567
18975
  const IonActionSheet = /*@__PURE__*/proxyCustomElement(ActionSheet, [34,"ion-action-sheet",{"overlayIndex":[2,"overlay-index"],"keyboardClose":[4,"keyboard-close"],"enterAnimation":[16],"leaveAnimation":[16],"buttons":[16],"cssClass":[1,"css-class"],"backdropDismiss":[4,"backdrop-dismiss"],"header":[1],"subHeader":[1,"sub-header"],"translucent":[4],"animated":[4],"htmlAttributes":[16]}]);
18568
18976
  const IonAlert = /*@__PURE__*/proxyCustomElement(Alert, [34,"ion-alert",{"overlayIndex":[2,"overlay-index"],"keyboardClose":[4,"keyboard-close"],"enterAnimation":[16],"leaveAnimation":[16],"cssClass":[1,"css-class"],"header":[1],"subHeader":[1,"sub-header"],"message":[1],"buttons":[16],"inputs":[1040],"backdropDismiss":[4,"backdrop-dismiss"],"translucent":[4],"animated":[4],"htmlAttributes":[16]},[[4,"keydown","onKeydown"]]]);
@@ -18623,9 +19031,9 @@ const IonRefresherContent = /*@__PURE__*/proxyCustomElement(RefresherContent, [0
18623
19031
  const IonReorder = /*@__PURE__*/proxyCustomElement(Reorder, [33,"ion-reorder",null,[[2,"click","onClick"]]]);
18624
19032
  const IonReorderGroup = /*@__PURE__*/proxyCustomElement(ReorderGroup, [0,"ion-reorder-group",{"disabled":[4],"state":[32]}]);
18625
19033
  const IonRippleEffect = /*@__PURE__*/proxyCustomElement(RippleEffect, [1,"ion-ripple-effect",{"type":[1]}]);
18626
- const IonRoute = /*@__PURE__*/proxyCustomElement(Route, [0,"ion-route",{"url":[1],"component":[1],"componentProps":[16],"beforeLeave":[16],"beforeEnter":[16]}]);
19034
+ const IonRoute = /*@__PURE__*/proxyCustomElement(Route$1, [0,"ion-route",{"url":[1],"component":[1],"componentProps":[16],"beforeLeave":[16],"beforeEnter":[16]}]);
18627
19035
  const IonRouteRedirect = /*@__PURE__*/proxyCustomElement(RouteRedirect, [0,"ion-route-redirect",{"from":[1],"to":[1]}]);
18628
- const IonRouter = /*@__PURE__*/proxyCustomElement(Router, [0,"ion-router",{"root":[1],"useHash":[4,"use-hash"]},[[8,"popstate","onPopState"],[4,"ionBackButton","onBackButton"]]]);
19036
+ const IonRouter = /*@__PURE__*/proxyCustomElement(Router$1, [0,"ion-router",{"root":[1],"useHash":[4,"use-hash"]},[[8,"popstate","onPopState"],[4,"ionBackButton","onBackButton"]]]);
18629
19037
  const IonRouterLink = /*@__PURE__*/proxyCustomElement(RouterLink, [1,"ion-router-link",{"color":[513],"href":[1],"rel":[1],"routerDirection":[1,"router-direction"],"routerAnimation":[16],"target":[1]}]);
18630
19038
  const IonRouterOutlet = /*@__PURE__*/proxyCustomElement(RouterOutlet, [1,"ion-router-outlet",{"mode":[1025],"delegate":[16],"animated":[4],"animation":[16],"swipeHandler":[16]}]);
18631
19039
  const IonRow = /*@__PURE__*/proxyCustomElement(Row, [1,"ion-row"]);
@@ -18652,15 +19060,17 @@ const IonToast = /*@__PURE__*/proxyCustomElement(Toast, [33,"ion-toast",{"overla
18652
19060
  const IonToggle = /*@__PURE__*/proxyCustomElement(Toggle, [33,"ion-toggle",{"color":[513],"name":[1],"checked":[1028],"disabled":[4],"value":[1],"activated":[32]}]);
18653
19061
  const IonToolbar = /*@__PURE__*/proxyCustomElement(Toolbar, [33,"ion-toolbar",{"color":[513]},[[0,"ionStyle","childrenStyle"]]]);
18654
19062
  const IonVirtualScroll = /*@__PURE__*/proxyCustomElement(VirtualScroll, [0,"ion-virtual-scroll",{"approxItemHeight":[2,"approx-item-height"],"approxHeaderHeight":[2,"approx-header-height"],"approxFooterHeight":[2,"approx-footer-height"],"headerFn":[16],"footerFn":[16],"items":[16],"itemHeight":[16],"headerHeight":[16],"footerHeight":[16],"renderItem":[16],"renderHeader":[16],"renderFooter":[16],"nodeRender":[16],"domRender":[16],"totalHeight":[32]},[[9,"resize","onResize"]]]);
18655
- const PosApp = /*@__PURE__*/proxyCustomElement(PosApp$1, [4,"pos-app",{"os":[32]},[[0,"consumeOs","consumeOs"]]]);
18656
- const PosDemoApp = /*@__PURE__*/proxyCustomElement(PosDemoApp$1, [0,"pos-demo-app",{"url":[32]},[[0,"pod-os:link","linkClicked"]]]);
19063
+ const PosApp = /*@__PURE__*/proxyCustomElement(PosApp$1, [4,"pos-app",{"os":[32]},[[0,"pod-os:init","initializeOs"]]]);
19064
+ const PosAppGeneric = /*@__PURE__*/proxyCustomElement(PosAppGeneric$1, [0,"pos-app-generic"]);
19065
+ const PosDemoApp = /*@__PURE__*/proxyCustomElement(PosDemoApp$1, [0,"pos-demo-app"]);
18657
19066
  const PosDescription = /*@__PURE__*/proxyCustomElement(PosDescription$1, [1,"pos-description",{"resource":[32]}]);
18658
- const PosLabel = /*@__PURE__*/proxyCustomElement(PosLabel$2, [1,"pos-label",{"resource":[32]}]);
19067
+ const PosLabel = /*@__PURE__*/proxyCustomElement(PosLabel$1, [1,"pos-label",{"resource":[32]}]);
18659
19068
  const PosLiterals = /*@__PURE__*/proxyCustomElement(PosLiterals$1, [1,"pos-literals",{"data":[32]}]);
18660
19069
  const PosLogin = /*@__PURE__*/proxyCustomElement(PosLogin$1, [0,"pos-login",{"os":[32]}]);
18661
19070
  const PosRelations = /*@__PURE__*/proxyCustomElement(PosRelations$1, [1,"pos-relations",{"data":[32]}]);
18662
19071
  const PosResource = /*@__PURE__*/proxyCustomElement(PosResource$1, [1,"pos-resource",{"uri":[1],"lazy":[4],"os":[32],"resource":[32],"consumers":[32],"error":[32],"loading":[32]},[[0,"pod-os:resource","provideResource"]]]);
18663
- const PosRichLink = /*@__PURE__*/proxyCustomElement(PosLabel$1, [1,"pos-rich-link",{"uri":[1]}]);
19072
+ const PosRichLink = /*@__PURE__*/proxyCustomElement(PosRichLink$1, [1,"pos-rich-link",{"uri":[1]}]);
19073
+ const PosRouter = /*@__PURE__*/proxyCustomElement(PosRouter$1, [0,"pos-router",{"uri":[32]},[[0,"pod-os:link","linkClicked"]]]);
18664
19074
  const defineCustomElements = (opts) => {
18665
19075
  if (typeof customElements !== 'undefined') {
18666
19076
  [
@@ -18753,6 +19163,7 @@ const defineCustomElements = (opts) => {
18753
19163
  IonToolbar,
18754
19164
  IonVirtualScroll,
18755
19165
  PosApp,
19166
+ PosAppGeneric,
18756
19167
  PosDemoApp,
18757
19168
  PosDescription,
18758
19169
  PosLabel,
@@ -18760,7 +19171,8 @@ const defineCustomElements = (opts) => {
18760
19171
  PosLogin,
18761
19172
  PosRelations,
18762
19173
  PosResource,
18763
- PosRichLink
19174
+ PosRichLink,
19175
+ PosRouter
18764
19176
  ].forEach(cmp => {
18765
19177
  if (!customElements.get(cmp.is)) {
18766
19178
  customElements.define(cmp.is, cmp, opts);
@@ -18769,4 +19181,4 @@ const defineCustomElements = (opts) => {
18769
19181
  }
18770
19182
  };
18771
19183
 
18772
- export { IonActionSheet, IonAlert, IonApp, IonAvatar, IonBackButton, IonBackdrop, IonBadge, IonButton, IonButtons, IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle, IonCheckbox, IonChip, IonCol, IonContent, IonDatetime, IonFab, IonFabButton, IonFabList, IonFooter, IonGrid, IonHeader, IonIcon, IonImg, IonInfiniteScroll, IonInfiniteScrollContent, IonInput, IonItem, IonItemDivider, IonItemGroup, IonItemOption, IonItemOptions, IonItemSliding, IonLabel, IonList, IonListHeader, IonLoading, IonMenu, IonMenuButton, IonMenuToggle, IonModal, IonNav, IonNavLink, IonNote, IonPicker, IonPickerColumn, IonPopover, IonProgressBar, IonRadio, IonRadioGroup, IonRange, IonRefresher, IonRefresherContent, IonReorder, IonReorderGroup, IonRippleEffect, IonRoute, IonRouteRedirect, IonRouter, IonRouterLink, IonRouterOutlet, IonRow, IonSearchbar, IonSegment, IonSegmentButton, IonSelect, IonSelectOption, IonSelectPopover, IonSkeletonText, IonSlide, IonSlides, IonSpinner, IonSplitPane, IonTab, IonTabBar, IonTabButton, IonTabs, IonText, IonTextarea, IonThumbnail, IonTitle, IonToast, IonToggle, IonToolbar, IonVirtualScroll, PosApp, PosDemoApp, PosDescription, PosLabel, PosLiterals, PosLogin, PosRelations, PosResource, PosRichLink, addEventListener as a, raf as b, componentOnReady as c, createGesture as d, defineCustomElements, clamp as e, createAnimation as f, getIonPageElement as g, now as n, pointerCoord as p, removeEventListener as r };
19184
+ export { IonActionSheet, IonAlert, IonApp, IonAvatar, IonBackButton, IonBackdrop, IonBadge, IonButton, IonButtons, IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle, IonCheckbox, IonChip, IonCol, IonContent, IonDatetime, IonFab, IonFabButton, IonFabList, IonFooter, IonGrid, IonHeader, IonIcon, IonImg, IonInfiniteScroll, IonInfiniteScrollContent, IonInput, IonItem, IonItemDivider, IonItemGroup, IonItemOption, IonItemOptions, IonItemSliding, IonLabel, IonList, IonListHeader, IonLoading, IonMenu, IonMenuButton, IonMenuToggle, IonModal, IonNav, IonNavLink, IonNote, IonPicker, IonPickerColumn, IonPopover, IonProgressBar, IonRadio, IonRadioGroup, IonRange, IonRefresher, IonRefresherContent, IonReorder, IonReorderGroup, IonRippleEffect, IonRoute, IonRouteRedirect, IonRouter, IonRouterLink, IonRouterOutlet, IonRow, IonSearchbar, IonSegment, IonSegmentButton, IonSelect, IonSelectOption, IonSelectPopover, IonSkeletonText, IonSlide, IonSlides, IonSpinner, IonSplitPane, IonTab, IonTabBar, IonTabButton, IonTabs, IonText, IonTextarea, IonThumbnail, IonTitle, IonToast, IonToggle, IonToolbar, IonVirtualScroll, PosApp, PosAppGeneric, PosDemoApp, PosDescription, PosLabel, PosLiterals, PosLogin, PosRelations, PosResource, PosRichLink, PosRouter, addEventListener as a, raf as b, componentOnReady as c, createGesture as d, defineCustomElements, clamp as e, createAnimation as f, getIonPageElement as g, now as n, pointerCoord as p, removeEventListener as r };