Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V4 new init #1171

Merged
merged 264 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
264 commits
Select commit Hold shift + click to select a range
7acb99c
BREAKING_CHANGE: new core/init
kobezzza Mar 1, 2024
03322bf
docs: updated docs
kobezzza Mar 1, 2024
4882c32
chore: refactoring for a new api
kobezzza Mar 1, 2024
4d244c9
fix: fixes for SSR
kobezzza Mar 1, 2024
ca5ea91
chore: restored some removed properties
kobezzza Mar 1, 2024
47e49f5
chore: fixed eslint
kobezzza Mar 1, 2024
c402cce
fix: removed dead code
kobezzza Mar 4, 2024
3bf9b12
chore: fixed eslint
kobezzza Mar 4, 2024
c37b830
refactor: review state initialization
kobezzza Mar 4, 2024
3c3796d
fix: fixed an error after refactoring
kobezzza Mar 4, 2024
009bbc6
chore: fixed eslint
kobezzza Mar 4, 2024
83686de
fix: fixed route normalization & review interfaces
kobezzza Mar 4, 2024
4504439
chore: fixed eslint
kobezzza Mar 4, 2024
0433dbf
chore: removed dead code
kobezzza Mar 4, 2024
5f689a8
fix: fixed race conditions
kobezzza Mar 4, 2024
2e5092c
chore: added tests
kobezzza Mar 4, 2024
0229139
chore: updated log
kobezzza Mar 4, 2024
20bdd69
chore: updated log
kobezzza Mar 5, 2024
6542df7
chore: merged issues/1147
kobezzza Mar 5, 2024
68cbcbd
Merge branch 'v4' into v4-new-init
kobezzza Mar 5, 2024
0039a09
chore(ssr)!: data preservation from providers is convenient for stati…
kobezzza Mar 6, 2024
79ed346
refactor(ssr): optimization for ssr
kobezzza Mar 6, 2024
d769157
docs: chat-gpt improvements
kobezzza Mar 6, 2024
c0a10e0
chore: fixed eslint
kobezzza Mar 6, 2024
df6a38a
fix: fixed SSR rendering
kobezzza Mar 6, 2024
23d3c1d
fix: fix after refactoring
kobezzza Mar 6, 2024
8a2f266
fix: fixed a typo
kobezzza Mar 7, 2024
0257cd3
chore: chatgpt improvements
kobezzza Mar 7, 2024
be02dd8
refactor!: renamed appId to appProcessId
kobezzza Mar 11, 2024
5988ae4
feat: added `isOnline` & `lastOnlineDate`
kobezzza Mar 11, 2024
e97b5bf
feat: added check-online
kobezzza Mar 11, 2024
80bc521
feat: added session bindings
kobezzza Mar 11, 2024
1cbe1d9
feat: restored isOnline & lastOnlineDate
kobezzza Mar 11, 2024
4e98742
fix: removed dead code
kobezzza Mar 11, 2024
1aa2c12
chore: merged with v4
kobezzza Mar 11, 2024
590e6b3
chore: fixed eslint
kobezzza Mar 11, 2024
6f5319e
fix: fixed get cookie
kobezzza Mar 11, 2024
c6819f4
fix: fixed invalid app property name
kobezzza Mar 11, 2024
eb3f849
fix: fixed caching
kobezzza Mar 11, 2024
af44f3b
Merge branch 'v4' into v4-new-init
kobezzza Mar 11, 2024
75192c4
chore: fixed TS types
kobezzza Mar 11, 2024
d66b0bd
chore: fixed TS types
kobezzza Mar 11, 2024
d6679ca
chore: :up:
kobezzza Mar 12, 2024
1211466
Merge branch 'v4' into v4-new-init
kobezzza Mar 12, 2024
e7e3f17
fix(ssr): loadModules should not operate during SSR
kobezzza Mar 13, 2024
f422850
fix(ssr): fixed memory leaks
kobezzza Mar 14, 2024
bf5720b
chore: fixed ESLint
kobezzza Mar 14, 2024
41c1825
fix(ssr): fixed memory leaks
kobezzza Mar 14, 2024
6dd1e2f
fix(ssr): fixed memory leaks
kobezzza Mar 14, 2024
3e1d08e
fix(ssr): fixed memory leaks
kobezzza Mar 15, 2024
bfc043f
fix(ssr): fixes for ssr
kobezzza Mar 15, 2024
524372e
fix(ssr): fixes for ssr
kobezzza Mar 15, 2024
9692ce3
fix(ssr): fixes for ssr
kobezzza Mar 15, 2024
e7feab3
fix(ssr): fixes for ssr
kobezzza Mar 18, 2024
e5173c6
Merge remote-tracking branch 'origin/v4' into v4-new-init
kobezzza Mar 18, 2024
7f35755
fix(ssr): fixes for ssr
kobezzza Mar 18, 2024
cd1ea60
fix(ssr): fixes for ssr
kobezzza Mar 18, 2024
ee6c40a
fix(ssr): using a vue-server-renderer fork for memory cleanup
kobezzza Mar 19, 2024
2a50dfd
feat(ssr): added support for watchers
kobezzza Mar 19, 2024
39336fb
fix(ssr): temporary disable watch decorators
kobezzza Mar 19, 2024
6349ce6
fix(ssr): fixes memory leaks
kobezzza Mar 20, 2024
6646ec0
fix(ssr): fixes memory leaks
kobezzza Mar 20, 2024
dfe7e13
chore: merged v4
kobezzza Mar 20, 2024
a79e3da
chore: rollback clearfix
kobezzza Mar 20, 2024
06bea9e
chore: deferred clearfix
kobezzza Mar 20, 2024
e8fde2d
fix: fixed a memory leak
kobezzza Mar 20, 2024
7daf5cd
chore: disable watching in SSR context
kobezzza Mar 20, 2024
d56ab39
fix: fixes for SSR
kobezzza Mar 20, 2024
8d69fc1
fix: fixes for SSR
kobezzza Mar 21, 2024
acedd87
fix(ssr): fixed a memory leak
kobezzza Mar 21, 2024
e6251da
fix(ssr): fixed memory leaks
kobezzza Mar 25, 2024
4bf3595
fix(ssr): fixed memory leaks
kobezzza Mar 25, 2024
d4bb8e9
fix: fixed a memory leak
kobezzza Mar 25, 2024
b2a00d3
fix: deferred destructor
kobezzza Mar 25, 2024
7bbc226
fix: fixed the error with premature state clearing
kobezzza Mar 28, 2024
e1893be
chore: fixed eslint
kobezzza Mar 28, 2024
f1a4db7
Fix no content api response hydration mismatch (#1210)
DennisPetrov Apr 1, 2024
816c7d9
chore: stylish fixes
kobezzza Apr 1, 2024
7dcf371
fix(ssr): fixed restoring state from the storage
kobezzza Apr 2, 2024
7261084
fix: fixed invalid this
kobezzza Apr 2, 2024
d2096d6
chore: merged v4
kobezzza Apr 3, 2024
9762748
chore: fixed eslint
kobezzza Apr 3, 2024
f802d54
Issues/1172 (#1174)
kobezzza Apr 3, 2024
fa2f509
chore: remove prefersColorScheme artifacts
Apr 3, 2024
72595cf
chore: fix test
Apr 3, 2024
6591f27
chore: fix test
Apr 3, 2024
1704554
refactor: export theme manager as default
kobezzza Apr 3, 2024
e695ead
chore: fixed imports
kobezzza Apr 3, 2024
a2e739e
chore: removed redundant code
kobezzza Apr 3, 2024
dabc7e8
Fixed an issue with test failing cause of missing styles
bonkalol Apr 3, 2024
36f1793
chore: fix tests
Apr 3, 2024
f0a7a2b
Merge branch 'v4-new-init' of github.com:V4Fire/Client into v4-new-init
Apr 3, 2024
fc6ae53
Revert "Fixed an issue with test failing cause of missing styles"
Apr 3, 2024
9017508
Refactoring page-meta (#1155)
bunin-av Apr 5, 2024
401d657
docs: improved doc
kobezzza Apr 5, 2024
c223f27
chore: fixed tests
kobezzza Apr 5, 2024
2c59866
chore: added doc header
kobezzza Apr 5, 2024
c826f17
chore: removed dead code
kobezzza Apr 9, 2024
c7f4cd3
chore: removed console
kobezzza Apr 9, 2024
f55780e
chore: update example for hydration
kobezzza Apr 9, 2024
b21dbee
chore: added SSR constant
kobezzza Apr 9, 2024
757cb52
chore: fixes for SSR
kobezzza Apr 9, 2024
905af9c
chore: fixes for SSR
kobezzza Apr 10, 2024
e459b3f
fix: fixed a memory leak
kobezzza Apr 11, 2024
faca25d
chore: merged v4
kobezzza Apr 15, 2024
52a4ce3
feat: added Snakeskin constant `SSR` to determine that the template i…
kobezzza Apr 16, 2024
75246c1
chore: updated log
kobezzza Apr 16, 2024
2ef4fad
feat: optimization for SSR template assembly
kobezzza Apr 16, 2024
5f090bd
fix(ssr): fixed string slots
kobezzza Apr 16, 2024
5307f42
chore: stylish and typos fixes
kobezzza Apr 17, 2024
a85b483
feat: added support for efficient rendering of the v-icon directive i…
kobezzza Apr 17, 2024
65f563b
chore: stylish fixes
kobezzza Apr 17, 2024
3b3d195
chore: added `getSSRContent`
kobezzza Apr 17, 2024
759bc25
refactor: use `innerHTML` prop
kobezzza Apr 17, 2024
b62be9f
chore: added support for effective SSR rendering
kobezzza Apr 17, 2024
f2d005b
refactor(ssr): better SSR support
kobezzza Apr 17, 2024
bcd17a2
chore: commited examples for tests
kobezzza Apr 17, 2024
4551c13
chore: merged v4
kobezzza Apr 19, 2024
b989d6a
feat(ssr): node directives transformer (#1243)
kobezzza Apr 19, 2024
29ec361
Merge branch 'v4' into v4-new-init
kobezzza Apr 19, 2024
787f959
Merge remote-tracking branch 'origin/v4-new-init' into v4-ssr-speedup
Apr 19, 2024
df78fa8
chore: fixed log
kobezzza Apr 19, 2024
70572bb
refactor: use SS rootTag
kobezzza Apr 19, 2024
ef10d31
fix: fixed hydration store initializing
kobezzza Apr 19, 2024
2d3f3fe
fix(ssr): fixes for ssr rendering
kobezzza Apr 22, 2024
ba2ac48
chore: mute eslint max-lines
kobezzza Apr 22, 2024
3d2b08c
fix(ssr): fixed SSR rendering
kobezzza Apr 22, 2024
ffbed3b
fix(ssr): fixed SSR rendering
kobezzza Apr 22, 2024
b8b5acc
feat: added optimization for v-tag
kobezzza Apr 23, 2024
337ab99
chore: updated dependencies
kobezzza Apr 23, 2024
0f0e403
fix: don't remove directives from transfromers
kobezzza Apr 23, 2024
1c6e2f2
feat(ssr): improved ssr rendering
kobezzza Apr 23, 2024
48a2ae3
chore: optimizing of SSR rendering
kobezzza Apr 25, 2024
bad01d3
chore: removed redundant code
kobezzza Apr 25, 2024
a7ce756
fix(ssr): fixed bugs during ssr
kobezzza Apr 25, 2024
3f83a46
fix(ssr): fixed bugs during ssr
kobezzza Apr 25, 2024
2cc6370
fix(ssr): fixed bugs during ssr
kobezzza Apr 25, 2024
12e9ff1
fix(ssr): fixed bugs during ssr
kobezzza Apr 25, 2024
533faaf
refactor: move `hydrationStore` to state (#1245)
ItMaga Apr 27, 2024
a5c8d36
feat: hydration cache middleware (#1250)
ItMaga Apr 27, 2024
493d16b
feat: hydration store incremental serializing (#1255)
ItMaga Apr 29, 2024
47dd7a7
chore: stylish fixes
kobezzza Apr 29, 2024
9f20df3
chore: stylish fixes
kobezzza May 2, 2024
3efe4aa
fix: fixed `setEmpty` & better error handling
kobezzza May 2, 2024
eab3fec
chore: fixed eslint
kobezzza May 2, 2024
741e969
fix: fixed initializing
kobezzza May 2, 2024
95d3027
Merge branch 'v4-new-init' into v4-ssr-speedup
kobezzza May 2, 2024
46018b8
chore: merged with v4
kobezzza May 2, 2024
61c7d6e
fix: fixed v-icon layout
kobezzza May 2, 2024
dfa90e6
feat: hydrate template styles (#1260)
ItMaga May 2, 2024
55b069d
chore: updated log
kobezzza May 2, 2024
80857c4
chore: some optimizations
kobezzza May 2, 2024
8a28be9
chore: some optimizations
kobezzza May 2, 2024
9f8d0c5
fix: fix after refactoring
kobezzza May 2, 2024
7e4271f
fix: fix the ssrRendering prop usage mechanism (#1218)
Dimeliora May 2, 2024
0ef5897
chore: updated log
kobezzza May 2, 2024
98b1a71
chore: added render optimizations
kobezzza May 3, 2024
86071ff
V4 i18n region (#1253)
Razdva122 May 6, 2024
79858e5
refactor: review `rootTag` logic
kobezzza May 6, 2024
9e947f7
Merge branch 'v4-new-init' of https://github.com/V4Fire/Client into v…
kobezzza May 6, 2024
ac73793
chore: updated cache
kobezzza May 6, 2024
6097b6e
chore: stylish fixes
kobezzza May 6, 2024
01f86c9
chore: stylish fixes
kobezzza May 6, 2024
7d8cc39
fix: ssr build (#1270)
kholstinin May 14, 2024
187e694
fix: new init tests (#1266)
ItMaga May 14, 2024
837fb76
chore: removed debug code
kobezzza May 14, 2024
3b42a6c
fix: ssr filename
kholstinin May 14, 2024
409c571
fix: remove unused imports
kholstinin May 14, 2024
6345402
chore: fixed vue warning
kobezzza May 14, 2024
c95f35d
feat: alias for vue/server-renderer
kholstinin May 15, 2024
140dc0e
chore: stylish fixes
kobezzza May 15, 2024
9ff47a1
feat: added b-cache-ssr
kobezzza May 15, 2024
6e7a045
chore!: the `renderComponentId` parameter has been replaced with `can…
kobezzza May 15, 2024
b9139c6
chore!: updated lock
kobezzza May 15, 2024
fe084c0
docs: added doc
kobezzza May 15, 2024
42f5a88
Merge branch 'v4-new-init' of https://github.com/V4Fire/Client into v…
kobezzza May 15, 2024
9f1145f
chore: grammar fixes
kobezzza May 15, 2024
0de315e
chore: only ssr prefetch
kobezzza May 15, 2024
2ce442c
fix: fixed cache logic
kobezzza May 15, 2024
a3b5eb9
fix: fixed cache logic
kobezzza May 15, 2024
36f4af3
fix: fix store iteration
May 18, 2024
00768f6
fix: add SSR engine for the Title element
May 18, 2024
4a8b30e
Merge pull request #1273 from V4Fire/dimeliora/page-meta-data-fix
Dimeliora May 20, 2024
2b4e30a
chore: merged with v4
kobezzza May 21, 2024
3fc9118
feat: add `cacheId` customization in hydration cache (#1282)
ItMaga May 23, 2024
3ec558b
fix: add conditional render of the page title
May 29, 2024
5dee163
chore: use HYDRATION const
May 29, 2024
1f7e519
Merge pull request #1287 from V4Fire/dimeliora/title-on-hydration-fix
Dimeliora May 30, 2024
b74e6dd
chore: merged with v4
kobezzza Jun 4, 2024
41a3c11
chore: improved doc
kobezzza Jun 4, 2024
d6da5c0
chore: merged with v4
kobezzza Jun 14, 2024
bf3e2af
refactor(i-block): location (#1309)
bunin-av Jun 17, 2024
06d91e6
fix: disable server-renderer for non ssr builds
kholstinin Jun 26, 2024
cb8191f
Merge branch 'v4-rc' into v4-new-init
shining-mind Jun 26, 2024
151f461
Activate component on hydration complete (#1326)
miniven Jul 8, 2024
b5ab531
chore: stylish fixes
kobezzza Jul 9, 2024
f108e2f
Add the 'response' emitting for the data-provider request (#1316)
Dimeliora Jul 10, 2024
e3cfe80
Merge branch 'v4' into v4-new-init
shining-mind Jul 10, 2024
9cce1f4
chore(build/webpack/optimization): remove unused variable "ssr"
shining-mind Jul 10, 2024
e23b33f
docs: fix changelog
shining-mind Jul 10, 2024
5937bb7
chore: removed DETECT_USER_PREFERENCES
kobezzza Jul 11, 2024
b7b0182
refactor: renamed `template.directives->template.transformableDirecti…
kobezzza Jul 11, 2024
d42da82
chore: added comment
kobezzza Jul 11, 2024
eba1719
chore: fixed log after merging
kobezzza Jul 11, 2024
2cc5f52
chore: improved doc
kobezzza Jul 11, 2024
ed28925
chore: merged with origin
kobezzza Jul 11, 2024
3a5b723
chore: merged with origin
kobezzza Jul 11, 2024
4da3af9
chore: fixed doc
kobezzza Jul 11, 2024
1871afe
chore: reversed rooTag spec
kobezzza Jul 11, 2024
71f77fc
chore: improved doc
kobezzza Jul 11, 2024
930cc11
chore: updated log
kobezzza Jul 11, 2024
f1f3e92
chore: improved doc
kobezzza Jul 11, 2024
b714985
chore: improved doc
kobezzza Jul 11, 2024
8aa1fcb
chore: removed redundant ts-ignore
kobezzza Jul 11, 2024
05d376b
chore: improved doc
kobezzza Jul 11, 2024
21fc1e2
chore: simplify
kobezzza Jul 11, 2024
8562ccd
chore: simplify
kobezzza Jul 11, 2024
949ab2e
chore: better types
kobezzza Jul 11, 2024
09149b9
chore: added comments
kobezzza Jul 11, 2024
5de7738
chore: added comments
kobezzza Jul 11, 2024
22fb8e7
fix: fixed session loading
kobezzza Jul 11, 2024
be97ea9
chore: updated log
kobezzza Jul 11, 2024
ba56f4c
chore: fixed doc
kobezzza Jul 11, 2024
62889be
fix: prefer nextTick
kobezzza Jul 11, 2024
2633eef
chore: stylish fixes
kobezzza Jul 11, 2024
a0e1efb
fix: added xss normalizing
kobezzza Jul 11, 2024
41340c9
fix: exclude jsdom
kobezzza Jul 11, 2024
e685a39
refactor: split modules
kobezzza Jul 12, 2024
1a5a2e4
feat: added core/html/xss
kobezzza Jul 12, 2024
32b57e7
chore: updated doc
kobezzza Jul 12, 2024
adb3e98
chore: removed xss library
kobezzza Jul 12, 2024
354e31b
chore: removed console.log
kobezzza Jul 12, 2024
b2a19c4
chore: fixed eslint
kobezzza Jul 12, 2024
4e5edc2
chore: updated lock
kobezzza Jul 12, 2024
659a059
refactor: simplify
kobezzza Jul 12, 2024
e7ac9b4
chore: stylish fixes
kobezzza Jul 12, 2024
677b8c7
chore: updating XSS API & spec
kobezzza Jul 12, 2024
595ee07
chore: updating doc
kobezzza Jul 12, 2024
5876592
fix: fixed import
kobezzza Jul 12, 2024
951ced1
chore: added comments
kobezzza Jul 12, 2024
dc1877c
fix: fixed SSR condition
kobezzza Jul 12, 2024
0d95d18
tests(core/component/render): test the event handler is patched in v-…
shining-mind Jul 12, 2024
195972c
tests(core/component/render): fix flags dummy
shining-mind Jul 12, 2024
44f6f32
Revert "fix: fixed SSR condition"
kobezzza Jul 12, 2024
857c18c
chore: updated log
kobezzza Jul 15, 2024
ed7eb02
fix: fixed tests
kobezzza Jul 15, 2024
b86d781
Update src/components/super/i-block/README.md
kobezzza Jul 15, 2024
1bab52b
chore: added comments & stylish refactoring
kobezzza Jul 15, 2024
230b20f
chore: added comments
kobezzza Jul 15, 2024
256f2e4
fix: xss
kobezzza Jul 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches: [master, v4, v4-rc]

jobs:
# Build project
# Build the project
build:
runs-on: ubuntu-latest
timeout-minutes: 60
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ Changelog

_Note: Gaps between patch versions are faulty, broken or test releases._

## v4.0.0-beta.?? (2024-??-??)

#### :boom: Breaking Change

* Added a wrapper for middleware with additional parameters `core/data/middlewares/hydration-cache`
* The modules `core/init` and `core/component/state` have been completely redesigned for the new API
* The field `locale` has been removed `iStaticPage`

#### :house: Internal

* Now SSR build is bundled into a single file
* Use the forked `lib/server-renderer` everywhere in the SSR build

## v4.0.0-beta.107 (2024-07-10)

#### :bug: Bug Fix
Expand Down
2 changes: 0 additions & 2 deletions build/globals.webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ module.exports = {
s(getThemes(getDS(), config.theme.include() || [config.theme.default()])) :
null,

DETECT_USER_PREFERENCES: s(config.theme.detectUserPreferences()),

POST_PROCESS_THEME: s(config.theme.postProcessor),

DS: runtime.passDesignSystem && pzlr.designSystem ?
Expand Down
2 changes: 1 addition & 1 deletion build/monic/attach-component-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ module.exports = async function attachComponentDependencies(str, filePath) {
if (webpack.ssr) {
if (!entryDeps.has(component.name)) {
styles.forEach(([key, style]) => {
decl += `require('core/component/hydration').styles.set('${key}', ${style});`;
decl += `require('core/hydration-store').styles.set('${key}', ${style});`;
});
}

Expand Down
11 changes: 4 additions & 7 deletions build/monic/dynamic-component-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,14 @@ module.exports = async function dynamicComponentImportReplacer(str) {

if (ssr) {
if (!entryDeps.has(resourceName)) {
imports.unshift(`require('core/component/hydration').styles.set('${resourceName}', (${decl})).get('${resourceName}')`);
imports.unshift(`require('core/hydration-store').styles.set('${resourceName}', (${decl})).get('${resourceName}')`);
}

} else {
decl = `function () { return ${decl}; }`;
imports[0] = `TPLS['${resourceName}'] ? ${imports[0]} : ${imports[0]}.then(${decl}, function (err) { stderr(err); return ${decl}(); })`;
return `[${imports.join(',')}]`;
}
}

if (ssr) {
return `[${imports.join(',')}]`;
decl = `function () { return ${decl}; }`;
imports[0] = `TPLS['${resourceName}'] ? ${imports[0]} : ${imports[0]}.then(${decl}, function (err) { stderr(err); return ${decl}(); })`;
}

return `Promise.all([${imports.join(',')}])`;
Expand Down
43 changes: 29 additions & 14 deletions build/snakeskin/default-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,42 @@ const
TYPE_OF = Symbol('Type of component to create'),
SMART_PROPS = Symbol('Smart component props');

const bind = {
const bemBind = {
bind: [
(o) => o.getVar('$attrs'),
'typeof rootTag !== "undefined" ? rootTag : undefined'
]
};

const tagNameBind = {
bind: [
...bemBind.bind,
'typeof forceRenderAsVNode !== "undefined" ? forceRenderAsVNode : undefined'
]
};

const tagBind = {
bind: [
...tagNameBind.bind,
'TPL_NAME',
'$i++'
]
};

Snakeskin.importFilters({
tagFilter: Snakeskin.setFilterParams(tagFilter, {bind: ['TPL_NAME', '$i++']}),
tagNameFilter: Snakeskin.setFilterParams(tagNameFilter, bind),
bemFilter: Snakeskin.setFilterParams(bemFilter, bind),
tagFilter: Snakeskin.setFilterParams(tagFilter, tagBind),
tagNameFilter: Snakeskin.setFilterParams(tagNameFilter, tagNameBind),
bemFilter: Snakeskin.setFilterParams(bemFilter, bemBind),
line: Snakeskin.setFilterParams((_, line) => line, {bind: [(o) => o.i]})
});

function tagFilter({name, attrs = {}}, tplName, cursor) {
Object.forEach(tagFilters, (filter) => filter({name, attrs}));
function tagFilter({name: tag, attrs = {}}, _, rootTag, forceRenderAsVNode, tplName, cursor) {
Object.forEach(tagFilters, (filter) => filter({tplName, tag, attrs, rootTag, forceRenderAsVNode}));

const isSimpleTag =
name !== 'component' &&
tag !== 'component' &&
!attrs[TYPE_OF] &&
!validators.blockName(name);
!validators.blockName(tag);

if (isSimpleTag) {
return;
Expand All @@ -63,7 +78,7 @@ function tagFilter({name, attrs = {}}, tplName, cursor) {
componentName = attrs[TYPE_OF];

} else {
componentName = name === 'component' ? 'iBlock' : name.camelize(false);
componentName = tag === 'component' ? 'iBlock' : tag.camelize(false);
}

const
Expand Down Expand Up @@ -133,21 +148,21 @@ function tagFilter({name, attrs = {}}, tplName, cursor) {
isSmartFunctional = attrs[SMART_PROPS] && (isFunctional || funcDir);

if (isFunctional && webpack.ssr) {
attrs[':renderComponentId'] = [false];
attrs[':canFunctional'] = [true];
}

if (isSmartFunctional) {
if (funcDir == null || funcDir === 'true') {
if (webpack.ssr) {
attrs[':renderComponentId'] = [false];
attrs[':canFunctional'] = [true];

} else {
attrs['is'] = [`${attrs['is'][0]}-functional`];
}

} else if (funcDir !== 'false') {
if (webpack.ssr) {
attrs[':renderComponentId'] = [!funcDir];
attrs[':canFunctional'] = [funcDir];

} else {
attrs[':is'] = [`'${attrs['is'][0]}' + (${funcDir} ? '-functional' : '')`];
Expand All @@ -157,12 +172,12 @@ function tagFilter({name, attrs = {}}, tplName, cursor) {
}
}

function tagNameFilter(tag, attrs, rootTag) {
function tagNameFilter(tag, attrs, rootTag, forceRenderAsVNode) {
attrs ??= {};

tag = $C(tagNameFilters)
.to(tag)
.reduce((tag, filter) => filter(tag, attrs, rootTag));
.reduce((tag, filter) => filter({tag, attrs, rootTag, forceRenderAsVNode}));

const
componentName = tag.camelize(false),
Expand Down
59 changes: 53 additions & 6 deletions build/snakeskin/filters/bem.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
const
{webpack} = require('@config/config');

const
visited = Symbol('visited');

module.exports = [
/**
* Integrates BEM classes to components: attaches identifiers, provides runtime transformers, etc.
Expand All @@ -23,18 +26,62 @@ module.exports = [
*/
function bem2Component(block, attrs, rootTag, element) {
const
elId = 'data-cached-class-component-id',
elName = element.replace(/^_+/, '');

// We add a class with componentId to each BEM element of our component.
// This is necessary for quickly locating such elements in the markup and avoiding problems with
// recursive components (where the class name of the element alone is not sufficient).
//
// Also, we have special props for passing classes and
// styles to specific component elements from an external component.
// For example,
//
// ```
// <b-example :classes="provide.classes({button: 'example'})" :styles="{button: 'color: red'}">
// ```
//
// Here, we have passed a new external CSS class and external styles to the button element.

// Explicitly set the necessary attributes for the most efficient template compilation under SSR
if (webpack.ssr) {
attrs[`:${elId}`] = ['String(renderComponentId)'];
const
provideClasses = `('classes' in self && classes?.['${elName}']) ?? []`,
provideStyles = `('styles' in self && styles?.['${elName}']) ?? []`;

if (attrs[visited]) {
attrs[':class'] = [`${attrs[':class'][0]}.concat(${provideClasses})`];
attrs[':style'] = [`${attrs[':style'][0]}.concat(${provideStyles})`];

} else {
attrs[visited] = true;

if (attrs[':class']) {
attrs[':class'] = [`[].concat((${attrs[':class'][0]}), !canFunctional ? componentId : "", ${provideClasses})`];

} else {
attrs[':class'] = [`[].concat(!canFunctional ? componentId : [], ${provideClasses})`];
}

if (attrs[':style']) {
attrs[':style'] = [`[].concat((${attrs[':style'][0]}), ${provideStyles})`];

} else {
attrs[':style'] = [`[].concat(${provideStyles})`];
}
}

// For client-side rendering, we set these values through a static data attribute,
// which will be expanded in the module `core/component/render/helpers/attrs.ts`.
// The issue is that if we simply insert the values explicitly,
// the template compilation won't be able to cache nodes with these parameters,
// even though the componentId and external classes/styles cannot change.
// Therefore, we use a special static attribute and later expand it in the transformer.
} else {
attrs[elId] = [true];
}
attrs['data-cached-class-component-id'] = [true];

const provide = 'data-cached-class-provided-classes-styles';
attrs[provide] = Array.concat([], attrs[provide], elName);
const provide = 'data-cached-class-provided-classes-styles';
attrs[provide] = Array.concat([], attrs[provide], elName);
}

return block + element;
}
Expand Down
37 changes: 22 additions & 15 deletions build/snakeskin/filters/tag-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ module.exports = [
/**
* Expands the `_` snippet as `<div v-tag=${rootTag}>`
*
* @param {string} tag
* @param {object} attrs
* @param {string} rootTag
* @param {object} params
* @param {string} params.tag
* @param {object} params.attrs
* @param {string} params.rootTag
* @param {boolean} params.forceRenderAsVNode
* @returns {string}
*
* @example
Expand All @@ -33,16 +35,18 @@ module.exports = [
* < _.bar
* ```
*/
function expandRootTag(tag, attrs, rootTag) {
function expandRootTag({tag, attrs, rootTag, forceRenderAsVNode}) {
if (tag === '_') {
const tag = rootTag ? [JSON.stringify(rootTag)] : ["rootTag || 'div'"];
attrs['v-tag'] = tag;
const
def = JSON.stringify(rootTag ?? 'div'),
tag = [`'rootTag' in self ? (rootTag || ${def}) : ${def}`];

if (webpack.ssr) {
if (webpack.ssr && forceRenderAsVNode) {
attrs[':is'] = tag;
return 'component';
}

attrs['v-tag'] = tag;
return 'div';
}

Expand All @@ -53,7 +57,8 @@ module.exports = [
* Expands the `:section` and `:/section` snippets.
* These snippets help to use semantics HTML tags, like `article` or `section` and don't care about the `h` levels.
*
* @param {string} tag
* @param {object} params
* @param {string} params.tag
* @returns {string}
*
* @example
Expand All @@ -65,7 +70,7 @@ module.exports = [
* < :/section
* ```
*/
function expandSection(tag) {
function expandSection({tag}) {
Vars.h = Vars.h ?? 0;

if (/^(.*):section$/.test(tag)) {
Expand Down Expand Up @@ -95,8 +100,9 @@ module.exports = [
/**
* Expands the `a:void` snippet as `<a href="javascript:void(0)">`
*
* @param {string} tag
* @param {object} attrs
* @param {object} params
* @param {string} params.tag
* @param {object} params.attrs
* @returns {string}
*
* @example
Expand All @@ -105,7 +111,7 @@ module.exports = [
* < a:void.bar
* ```
*/
function expandVoidLink(tag, attrs) {
function expandVoidLink({tag, attrs}) {
if (/^a:void$/.test(tag)) {
attrs.href = ['javascript:void(0)'];
return 'a';
Expand All @@ -117,8 +123,9 @@ module.exports = [
/**
* Expands the `button:link` snippet as `<button class="a">`
*
* @param {string} tag
* @param {object} attrs
* @param {object} params
* @param {string} params.tag
* @param {object} params.attrs
* @returns {string}
*
* @example
Expand All @@ -127,7 +134,7 @@ module.exports = [
* < button:link.bar
* ```
*/
function expandButtonLink(tag, attrs) {
function expandButtonLink({tag, attrs}) {
if (/^button:a$/.test(tag)) {
attrs.type = ['button'];
attrs.class = Array.concat([], attrs.class, 'a');
Expand Down
Loading
Loading